要保证delete的行与UPDATE的行不冲突。

解决方案 »

  1.   

    where rowid <> :new.rowid;
      

  2.   

    SQL> create table a (id varchar2(1),name varchar2(10));Table createdSQL> insert into a values('1','fff');1 row insertedSQL> create trigger a_tri
      2  before update or delete on a
      3  for each row
      4  begin
      5  if updating then
      6  delete from a where id=:new.id;
      7  else
      8  null;
      9  end if;
     10  end;
     11  /Trigger createdSQL> update a set name='ddd';update a set name='ddd'ORA-04091: 表 ECSQUERY.A 发生了变化,触发器/函数不能读
    ORA-06512: 在"ECSQUERY.A_TRI", line 3
    ORA-04088: 触发器 'ECSQUERY.A_TRI' 执行过程中出错
      

  3.   

    对不起,楼主!csusmart(csusmart) 与 beckhambobo(beckham)说的对!
      

  4.   

    触发器不能读写变异表 你的表 A下面的可以解决 但好像不安全SQL> create table t(n number);SQL> insert into t values(1);
    SQL> insert into t values(3);
    commitcreate or replace trigger t_t before update on t for each row
    declare
      pragma autonomous_transaction;
    begin
      if :new.n=2 then
        delete from t where n=1;
      end if;
      commit;
    end;
    /
    触发器已创建SQL> update t set n=2 where n=3;已更新 1 行。SQL> select * from t;         N
    ----------
             2