對不起我的英語不好。我有2張桌子:Table1idtable2_idnummodification_date 和Table2idtable2num我想打一個觸發(fā)器,它插入或刪除操作后在Table1更新的最后一個值num的Table2.table1lastnum。我的觸發(fā)器:CREATE OR REPLACE TRIGGER TABLE1_NUM_TRG AFTER INSERT OR DELETE ON table1 FOR EACH ROWBEGIN IF INSERTING then UPDATE table2 SET table2num = :new.num WHERE table2.id = :new.table2_id; ELSE UPDATE table2 SET table2num = (SELECT num FROM (SELECT num FROM table1 WHERE table2_id = :old.table2_id ORDER BY modification_date DESC) WHERE ROWNUM <= 1) WHERE table2.id = :old.table2_id; END IF;END TABLE1_NUM_TRG; 但刪除后Table1我有錯誤:ORA-04091: table BD.TABLE1 is mutating, trigger/function may not see itORA-06512: at "BD.TABLE1_NUM_TRG", line 11ORA-04088: error during execution of trigger 'BD.TABLE1_NUM_TRG'我究竟做錯了什么?
- 2 回答
- 0 關注
- 1328 瀏覽
添加回答
舉報
0/150
提交
取消