首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

行级触发器对当前表操作,”ORA-04091: 表 COMPANY 发生了变化, 触发器/函数不能读它“,解决办法

2012-07-26 
行级触发器对当前表操作,”ORA-04091: 表 COMPANY 发生了变化, 触发器/函数不能读它“,解决方法?行级触发器

行级触发器对当前表操作,”ORA-04091: 表 COMPANY 发生了变化, 触发器/函数不能读它“,解决方法

?

行级触发器对当前表操作,”ORA-04091: 表 COMPANY 发生了变化, 触发器/函数不能读它“,解决方法:

1、自动产生另外一个独立的TRANSACTION,一般需要在其中写commit,见红色内容

?

create or replace trigger odpaydetailTrigger  before insert or update on order_pay_detail    for each rowdeclare  PRAGMA AUTONOMOUS_TRANSACTION;--自动产生另外一个独立的TRANSACTION,一般需要在其中写commit  -- local variables here 一个订单 pay_reason=‘MAIN’只能有一个  detailcount int;  begin  if :new.pay_reason='MAIN' then      begin          if inserting then                begin                        select count(1) into detailcount from order_pay_detail opd where opd.order_package_id=:new.order_package_id and opd.pay_reason='MAIN' AND PAY_SUC='Y';                        if detailcount>=1 then                           begin                                 raise_application_error(-20020, '重复插入类型为MAIN的支付明细');                           end;                        end if;                 end;           end if;           if updating then                begin                        --select count(*) into detailcount from order_pay_detail opd where opd.order_package_id=:new.order_package_id and opd.pay_reason='MAIN';                        if (:new.pay_reason<>:old.pay_reason or :new.PAY_SUC<>:old.PAY_SUC) and :new.pay_reason='MAIN' and :new.PAY_SUC='Y' then                           begin                                select count(1) into detailcount from order_pay_detail opd where opd.order_package_id=:new.order_package_id and opd.pay_reason='MAIN' AND PAY_SUC='Y';                                if detailcount >=1 then                                    begin                                    raise_application_error(-20020, '重复插入类型为MAIN的支付明细');                                    end;                                end if;                             end;                        end if;                 end;           end if;     end;  end if;    COMMIT;end odpaydetailTrigger;
?

?

?

?

?

?

?

热点排行