报错 Ora-04091  table XXX is mutating  ,trigger/function may not see it 
我的用法是,删除表 A 的时候触发删除 表 B的关联内容,删除表B的内容级联删除 表C 的关联内容 ,这个错就是直接删除A的记录的时候出现的不知道该如何处理,关键是并不是所有的情况都会报错,有时候也是正常的。或者Oracle 9.2 不支持这种触发器的做法。。
CSDN 的高手们  请教了!!
 

解决方案 »

  1.   

    drop table table_a;
    drop table table_b;
    drop table table_c;
    create table table_a(id int,name varchar2(10));
    insert into table_a values(1,'zxf');
    insert into table_a values(2,'fff');create table table_b(id int,des varchar2(20),p_id int);
    insert into table_b values(1,'dddd',1);
    insert into table_b values(2,'cccc',1);
    insert into table_b values(3,'aaaa',2);create table table_c(id int,treedesc varchar2(20),p_id int);
    insert into table_c values(1,'dddddd',1);
    insert into table_c values(2,'ddddda',2);
    insert into table_c values(3,'afasfd',3);create or replace trigger tri_a_d_table_a
    after delete on table_a for each row
    begin
      delete from table_b where p_id=:old.id;
    end;create or replace trigger tri_a_d_table_b
    after delete on table_b for each row
    begin
      delete from table_c where p_id=:old.id;
    end;delete from table_a where id=1;我试了没有问题.
      

  2.   

    有没有建主外建,或者是不是有变异表的操作,把trigger贴出来看看。
      

  3.   

    其实不用建立触发器器就可以搞定的,on delete cascade就可以乐