表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