oracle触发器触发需要查询的表(ORA-04091报错处理)----gxl

CREATE OR REPLACE Trigger Pdm_wfproc_gjy
  After Insert Or Update On Cpcwfproc
  For Each Row
  when (new.procid =1 and new.stat = 7)--分开事务了最好加上条件,确保前置数据拥有
		
declare
  
  Pragma autonomous_transaction; ----这段可以确保触发器表与下面查询语句表分开事务
  x_wftempid Integer;

Begin
	

 ---raise_application_error(-20000,'wfid='||:new.wfid);
 select w.wftempid into x_wftempid from cpcwf w where w.wfid = :new.wfid;--不加条件在当前场景就报错了
 
	
  if x_wftempid in (135, 134, 133, 27) then
  
    update yfps_cache_trigger t
       set (t.aendtime, t.endtime, t.period, t.aendtime2, t.sylb) =
           (Select C2.Aendtime as aendtime,
                   C2.Aendtime Endtime,
                   To_Number(Round(C2.Aperiod / 8, 2)) Period,
                   C2.Aendtime Aendtime2,
                   Decode(w.Wftempid,
                          27,
                          '量产',
                          135,
                          '单独送样',
                          134,
                          '二次送样流程',
                          133,
                          '首次送样流程',
                          w.Wftempid) Sylb
              From User_Yryskfpfd a, Cpcshtins s, Cpcwfproc c2, Cpcwf w
             Where s.Shtinsid = a.Shtinsid
               And s.Visible = 2
               And C2.Wfid = s.Wfid
               And C2.Stat = 7
               And C2.Procid = 18
               And a.Yfy <> 'admin'
               and s.wfid = :new.wfid)  
     where exists (select 1 from Cpcshtins s where s.wfid = :new.wfid and s.shtinsid = t.shtinsid);

commit;----这句是必须了,不然又有新的报错了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值