表1:客戶如果使用Oracle中陳述引發
CUST_NO | cust_credbal | cred_status
表2:customer_credittopup
CUST_NO | trans_amount
我有以上兩個表,我已經寫了一個更新觸發器插入到Table2
後更新Table1
。因此Table1
cust_credbal
中的金額在cust_credbal
Tabl1
+ trans_amount
Table2
的新值後更新。如何添加的,如果在更新後聲明,以檢查是否cust_credbal
爲> 20,然後cred_status
被設定爲別人的EXHAUSTED「「有效」
我的觸發顯示此錯誤:錯誤在第8行:PLS-00049:壞綁定變量 'NEW.CUST_CREDITBAL'
CREATE OR REPLACE TRIGGER after_insert_credittopup
AFTER INSERT ON customer_credittopup
FOR EACH ROW
DECLARE
credit number(11);
BEGIN
UPDATE customers
SET cust_creditbal=cust_creditbal +:new.trans_amount
WHERE cust_no=:new.cust_no;
SELECT Cust_creditbal INTO credit
FROM customers WHERE cust_no=:new.cust_no;
IF(:new.cust_creditbal>0) THEN
UPDATE customers
SET Cust_credstatus='Valid'
WHERE cust_no=:new.cust_no;
end if;
end;
/
哪個表有'cust_creditbal'字段?如果它在'customers'中,':new.cust_creditbal'只會在'customers'表的觸發器中才有意義。 – a1ex07