触发器造成死锁问题
表A有以下列:divid, d_xmid, d_ypx, d_xpx,
表B有以下列:divid, projectid d_xmpx1
其中:divid=divid,xmid=projectid
现在有如下业务要求:如果A表的d_xpx发生update,就把更新的数值触发到B表的d_xmpx1。同时又把这个数值也触发到A表的d_ypx。
我现在的实现方式:在A表建一个触发器:
create or replace trigger A_update
after UPDATE OF d_xpx
on A
for each row
begin
update B set d_xmpx1 =:new.d_xpx where divid=:old.divid and :old.d_xmid=projectid;
end;
同时又在B表建一个触发器:
create or replace trigger B_update
after update of d_xmpx1
on B
for each row
declare
pragma autonomous_transaction;
begin
update A set d_ypx=:new.d_xmpx1;
end;
出现的问题:只要执行A表的update,就会提示死锁。有什么解决办法吗