创建以下VendorAccount表
VendorAccount
(Ven_AccountId,
Ven_RegNo,
Ven_Invoice_RefNo,
TotalAmount,
Paid_ToVen ,
Balance
)
在上表中,TotalAmount的值来自另一个表(Vendor_InvoiceDetails
)。通过POPUP LOV选择TOTALBALANCE值。
从Pad_TOVEN
(TOTALAMOUNT
)中减去TotalAMount-Pad_TOVEN
金额。当我选择TOTALAMOUNT
时,它会给我旧的TOTAL VALUE
,如下图所示。
我希望更新该值。当我选择TotalAmount时,它应该在新条目的Ven_Invoice_RefNo
列中基于TotalAmount
i-e 2300给我新的更新值。下面是触发器,但它有以下错误
错误:PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current curs
触发:
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;
答案 0 :(得分:1)
据我所知,有五件事要做:
只有一个“进入”。
create or replace trigger "VENDORACCOUNT_T2"
BEFORE
insert or update or delete on "VENDORACCOUNT"
for each row
DECLARE new_balance INT;
new_total INT;
new_paid INT;
old_balance INT;
old_total INT;
begin
SELECT balance, total, PAID_TOVEN
INTO old_balance, old_total, 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;
答案 1 :(得分:0)
您应该在'begin'之前移动声明部分