今天项目组报一个触发器ora-04091错误:
before insert or delete or update on aaa
for each row
declare
maxsss number;
begin
pro_test(:new.a);
end;
create or replace procedure pro_test(a number) is
mm number;
begin
dbms_output.put_line(a);
select count(*) into mm from aaa;
end;
update aaa set aaa.a=1;
ERROR at line 1:
ORA-04091: table SCOTT.AAA is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.PRO_TEST", line 5
ORA-06512: at "SCOTT.TRI_AAA", line 4
ORA-04088: error during execution of trigger 'SCOTT.TRI_AAA'
经检查发现在触发器里对触发的表进行了查询操作导致的,解决的办法是:
PRAGMA AUTONOMOUS_TRANSACTION; 加独立事务处理,然后再在过程中加入commit进行一次提交问题解决!
[@more@]