触发此触发器时收到错误ORA-04091:
CREATE OR REPLACE TRIGGER SendNotifications
AFTER UPDATE OF penalty_amount ON Penalites
FOR EACH ROW
DECLARE
phone_no number(9,0);
BEGIN
SELECT PHONE_NUMBER INTO phone_no
FROM ADRESSES
INNER JOIN ORDERS
ON adresses.ID_READER = orders.ID_READER
INNER JOIN PENALITES
ON orders.ID_ORDER = penalites.ID_ORDER
WHERE :new.ISPAID = 'N';
DBMS_OUTPUT.PUT_LINE('Phone numbers where selected.');
END;
/
我想我应该使用:new。和:老。但我不知道如何处理它。你能给我任何建议或起点吗?
答案 0 :(得分:0)
触发器中的SELECT语句正在尝试从PENALTIES
检索数据,该表是定义触发器的表。不允许这样的行触发器从定义它们的表中检索数据。您有三种选择:
FOR EACH ROW
或从SELECT语句中删除PENALTIES
。看来这个陈述会做同等的事情:
SELECT PHONE_NUMBER
FROM ADRESSES
INNER JOIN ORDERS
ON adresses.ID_READER = orders.ID_READER
WHERE :new.ISPAID = 'N' AND
orders.ID_ORDER = :new.ID_ORDER;
将此转换为复合触发器。 See this answer for details
祝你好运。