复制代码 代码如下:
income{
id number;
pay_amount number;(入库金额字段)
}
outlay{
id number;
outlay_amount number;(出库金额字段)
}
balance
{
id number;
balance number;(余额字段)
}
复制代码 代码如下:
CREATE TRIGGER "AA"."TRI_ADD" AFTER
INSERT
OR DELETE ON "INCOME" FOR EACH ROW begin
if deleting then
update balance set balance = nvl(balance,0) - :old.pay_amount;
elsif updating then
update balance set balance = nvl(balance,0) - :old.pay_amount + :new.pay_amount;
else
update balance set balance = nvl(balance,0) + :new.pay_amount;
end if;
end;
复制代码 代码如下:
CREATE TRIGGER "AA"."TRI_CUT" AFTER
INSERT
OR DELETE
OR UPDATE ON "OUTLAY" FOR EACH ROW begin
if deleting then
update balance set balance = nvl(balance,0) + :old.outlay_amount;
elsif updating then
update balance set balance = nvl(balance,0) + :old.outlay_amount - :new.outlay_amount;
else
update balance set balance = nvl(balance,0) - :new.outlay_amount;
end if;
end;
复制代码 代码如下:
if inserting then
-----
elsif updating then
-----
elsif deleting then
------
end if;
新闻热点
疑难解答