我创建了一个具有以下属性的表:
TABLE "VENDORACCOUNT"
( "VEN_ACCOUNTID"
"VEN_REGNO"
"VEN_TXDATE"
"VEN_INVOICE_REFNO"
"TOTALAMOUNT"
"PAID_TOVEN"
"BALANCE"
)
我根据其值从另一个表中获取TOTALAMOUNT
列值。这里的场景是从列值中减去列值。但是下次我选择该值时,它不会显示更新的值。它向我显示了旧值,如下面的报告所示。 POPUP LOV
VEN_INVOICE_REFNO
TOTALAMOUNT
PAID_TOVEN
TOTALAMOUNT
报告查询:
select "VEN_ACCOUNTID",
"VEN_REGNO" ,
"VEN_TXDATE" ,
"VEN_INVOICE_REFNO" as ,
"TOTALAMOUNT" as ,
"PAID_TOVEN" as ,
TOTALAMOUNT-PAID_TOVEN as "Balance"
from "VENDORACCOUNT"
在上面的报告中,我希望每当我做第二个条目时,它应该向我显示减去或更新的值,即分别1800
代替2800
和4550
代替9550
。所以下次我可以从1800
和中减去金额4550
。
我创建了这个触发器
create or replace trigger "VENDORACCOUNT_T2"
BEFORE
insert or update or delete on "VENDORACCOUNT"
for each row
begin
DECLARE new_balance INT;
DECLARE new_total INT;
DECLARE new_paid INT;
SELECT balance INTO old_balance,
total INTO old_total,
PAID_TOVEN INTO new_paid
FROM vendoraccount
WHERE ven_regno = new.ven_regno
AND VEN_INVOICE_REFNO = new.VEN_INVOICE_REFNO;
UPDATE vendoraccount SET TOTALAMOUNT = old_total + old_balance - new_paid,
balance = TOTALAMOUNT - new_paid
WHERE VEN_REGNO= new.VEN_REGNO
AND VEN_INVOICE_REFNO = new.VEN_INVOICE_REFNO;
end;
并收到此错误:
错误:PLS-00103:'在预期以下情况之一时遇到符号“DECLARE”:开始函数杂注过程子类型类型当前 curs'