小编典典

变异,触发器/函数可能看不到它-执行触发器时出错

sql

CREATE OR REPLACE TRIGGER UPDATE_TEST_280510
AFTER insert on TEST_TRNCOMPVISIT
declare
V_TRNCOMPNO NUMBER(10);

CURSOR C1 IS SELECT B.COMPNO FROM TEST_TRNCOMPVISIT A, TEST_TRNCOMPMST B, 
                                  TEST_MEMMAST C
WHERE A.COMPNO=B.COMPNO 
AND B.TRNMEMID=C.MEMID 
AND C.MEMOS>=1000;

begin
open c1;
fetch c1 into V_TRNCOMPNO;


UPDATE TEST_TRNCOMPMST SET COMPSTATUS='P',
       remark='comp is pending due to O/S>1000'
WHERE COMPNO=V_TRNCOMPNO AND COMPSTATUS='C';
CLOSE C1;

end;

我做了这个触发器,在将行插入表TEST_TRNCOMPVISIT时,出现以下错误-

发生以下错误:

ORA-04091:表TEST.TEST_TRNCOMPVISIT正在变异,触发器/函数可能看不到它
ORA-06512:在“ TEST.UPDATE_TEST_280510”,第4行
ORA-06512:在“ TEST.UPDATE_TEST_280510”,第10行
ORA-04088:在执行期间出错执行触发器“ TEST.UPDATE_TEST_280510”


阅读 173

收藏
2021-03-23

共1个答案

小编典典

这是您唯一的触发器吗?您的触发器更新表TEST_TRNCOMPMST。如果此表上有一个访问TEST_TRNCOMPVISIT的触发器,则会收到错误消息。

2021-03-23