请各位大侠帮看一下这个oracle触发器那里出错了
create or replace trigger test1
after insert or update or delete
on libfile2
for each row
--declare
-- PRAGMA AUTONOMOUS_TRANSACTION;
begin
  if deleting then
   declare
   vol_ownervol libvol2.keyword%type;
   file_keyword libfile2.keyword%type;
   begin
     select :old.ownervol into vol_ownervol from dual;
  -- select :old.keyword into file_keyword from dual;
   update libvol2  set f2=(select sum(f8) from libfile2 where ownervol=vol_ownervol),f3=(select count(*) from libfile2 where ownervol=vol_ownervol) where libvol2.keyword = vol_ownervol;
--commit;
  end;
  else
  declare
  vol_ownervol libvol2.keyword%type;
  file_keyword libfile2.keyword%type;
    begin   
    select :new.ownervol into vol_ownervol from dual;
  --select :new.keyword into file_keyword from dual;
     update libvol2  set f2=(select sum(f8) from libfile2 where ownervol=vol_ownervol),f3=(select count(*) from libfile2 where ownervol=vol_ownervol) where libvol2.keyword = vol_ownervol;
--commit;
end;
end if;
end;
能正常编译;但触发时出错:ora-04091 表xx发生了变化,触发器/函数不能读它
------解决方案--------------------可能是触发器中的逻辑在触发器本身还没有执行完时,又导致了重新触发;
你  update libvol2  ,是否在libvol2 也有触发器,导致更改 libfile2。
------解决方案--------------------和触发器无关,是你的逻辑没理清。
举个最简单例子:我修改某列数据时,要求这数值不能大于此列平均值,那么我计算平均数时包含了当前行,那我应该取何时的数据?这和Oracle的事务处理逻辑有关。
1 用你注释掉的自治事务处理
2 把逻辑改正。