指定自由事务处理 解决触发器中不能提交事务问题

create or replace trigger "update_reimburse_instr_cnaps" before insert on bs_reimburse_instr_detail
for each row
declare 
pragma autonomous_transaction;--指定自由事务处理 解决触发器中不能提交事务问题
count_ integer;
begin
  dbms_output.put_line(:new.main_batch_no);
  select count(*) into count_ from bs_reimburse_instruction_main m where m.batch_no = :new.main_batch_no and (m.pay_branch_name like '%中行%' or m.pay_branch_name like '%中国银行%');
  --dbms_output.put_line(count_);
 if count_ > 0 then
   update bs_reimburse_instr_detail s
     set s.receive_bank_code =
         (select distinct bs.recbankcode
            from bs_bankinstructioninfo bs
           where 1 = 1
             and bs.receiveaccountno = s.receive_account_no
             and bs.instrstatus = 3
             and rownum = 1)
   where s.receive_bank_code is null and s.main_batch_no = :new.main_batch_no;
/*   
   update bs_reimburse_instr_detail ss
      set ss.receive_bank_code =
          (select s3.receive_bank_code
             from bs_reimburse_instr_detail s3
            where s3.receive_account_no = ss.receive_account_no and s3.instr_status = 3 and rownum = 1 and s3.receive_bank_code is not null);
*/
  commit;
 end if;
end; 

发布了66 篇原创文章 · 获赞 19 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/hwq293/article/details/102911589