一个简单的2行代码的触发器,希望各位帮忙,谢谢。
create or replace trigger tr_GC_YSZB
  after Insert Or Update  on   GC_YSZB
  for each row
Declare
  ysfy NUMBER(15,2);
Begin
  Select sum(YSZB_JE)  Into ysfy From GC_YSZB where YSZB_BH=:New.yszb_bh
  update GC_XM set XM_YSZE=ysfy where xm_BH=:New.yszb_bh;
end tr_GC_YSZB;
ora-04091:GC_YSZB发生变化,触发器/函数不能读
ora-06512:TR_GC_YSZB,line 5
ora-04088:触发器'TR_GC_YSZB'执行过程中出错

解决方案 »

  1.   

    create or replace trigger tr_GC_YSZB
      after Insert Or Update  on   GC_YSZB
      for each row
    Declare
      ysfy NUMBER(15,2);
      temp varchar2(20);
    Begin
       temp := =:New.yszb_bh;
      Select sum(YSZB_JE)  Into ysfy From GC_YSZB where YSZB_BH=:New.yszb_bh
      update GC_XM set XM_YSZE=ysfy where xm_BH=temp;
    end tr_GC_YSZB;
      

  2.   

    create or replace trigger tr_GC_YSZB
      after Insert Or Update  on   GC_YSZB
      for each row
    Declare
      ysfy NUMBER(15,2);
      temp varchar2(20);
    Begin
       temp := =:New.yszb_bh;
      Select sum(YSZB_JE)  Into ysfy From GC_YSZB where YSZB_BH=tesp;
      update GC_XM set XM_YSZE=ysfy where xm_BH=temp;
    end tr_GC_YSZB
      

  3.   

    create or replace trigger tr_GC_YSZB
      after Insert Or Update  on   GC_YSZB
      for each row
    Declare
      ysfy NUMBER(15,2);
      pragma autonomous_transaction;
    Begin
      Select sum(YSZB_JE)  Into ysfy From GC_YSZB where YSZB_BH=:New.yszb_bh;
      update GC_XM set XM_YSZE=ysfy where xm_BH=:New.yszb_bh;
    end tr_GC_YSZB;
    这样应该可以吧,;是一个问题,主要的还是要加 pragma autonomous_transaction;
      

  4.   

    还是不行啊。
    *com.exp.dao.EXPSQLException:ORA-06519: 检测到活动的自治事务处理,已经回退 ORA-06512: 在"TMS.TR_GC_YSZB", line 7 ORA-04088: 触发器 'TMS.TR_GC_YSZB' 执行过程中出错 [ 详细信息请查看系统异常日志]