我创建了Trigger,它检查广告表中的付款并且应该更新另一个表(customer_account)是否有人知道bug在哪里?
CREATE OR REPLACE TRIGGER Payment_check
after UPDATE ON Ads
FOR EACH ROW
BEGIN
IF NEW.Pay_done==('y'||'Y')THEN
UPDATE customer_account SET customer_account.Plcd_ads = NEW.Ad_id
WHERE customer_account.C_id = NEW.Customer;
ELSE
UPDATE customer_account SET customer_account.Pend_ads = NEW.Ad_id
WHERE customer_account.C_id = NEW.Customer;
END IF;
END;
//////bug
Error at line 7: PLS-00103: Encountered the symbol "." when expecting one of the following:
mod
continue current sql execute forall merge
pipe purge
The symbol "" was substituted for "." to continue.
5. IF NEW.Pay_done==('y'||'Y')THEN
6. UPDATE customer_account SET customer_account.Plcd_ads = NEW.Ad_id
7. WHERE customer_account.C_id = NEW.Customer;
8. ELSE
9. UPDATE customer_account SET customer_account.Pend_ads = NEW.Ad_id
答案 0 :(得分:5)
还请提供表格创建语句,以便轻松重现您的错误。
以下是两个可能的问题。如果这不能解决错误,请更改这些并更新问题。
1)新运营商需要以“:”为前缀
2)检查pay_done标志的条件可能只是“上限(:NEW.Pay_done)='Y'”
CREATE OR REPLACE TRIGGER Payment_check
AFTER UPDATE
ON Ads
FOR EACH ROW
BEGIN
IF upper(:NEW.Pay_done) = 'Y' THEN
UPDATE customer_account SET customer_account.Plcd_ads = :NEW.Ad_id
WHERE customer_account.C_id = NEW.Customer;
ELSE
UPDATE customer_account SET customer_account.Pend_ads = :NEW.Ad_id
WHERE customer_account.C_id = :NEW.Customer;
END IF;
END;
答案 1 :(得分:0)
Rajesh Chamarthi感谢您的回复,您的代码也无法正常工作,但有助于找到我的朋友。在新值和
之前缺少的冒号 IF NEW.Pay_done==('y'||'Y')THEN
changed for
IF NEW.Pay_done=('y'||'Y')THEN
工作!