创建了以下 VendorAccount 表
VendorAccount
(Ven_AccountId,
Ven_RegNo,
Ven_Invoice_RefNo,
TotalAmount,
Paid_ToVen ,
Balance
)
在上表中,TotalAmount 的值来自另一个 Table( Vendor_InvoiceDetails
)。TOTALBALANCE 值是通过 POPUP LOV 选择的。
Pad_TOVEN
金额从TOTALAMOUNT
( ) 中减去。TotalAMount-Pad_TOVEN
当我选择TOTALAMOUNT
它时,它会给我旧TOTAL VALUE
的,如下图所示。
我想要更新的值。当我选择 TotalAmount 时,它应该根据新条目的列中的Ven_Invoice_RefNo
2300为我提供新的更新值。TotalAmount
下面是触发器,但它有休闲错误
错误: 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;