高手帮忙,oracle触发器问题

就是一个昵称嘛 就是一个昵称嘛 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
向表中插入数据时,表上有触发器,爆出如下错误:
ora-04091 table TASK_FLOW_LOG is mutating, trigger/function may not see it

这是我的触发器

create or replace trigger "TRG_TASK_FLOW_LOG"
before insert on task_flow_log
for each row
declare
I_count integer;
data_unique_exception exception;
begin

if :new.seq is null then
raise data_unique_exception;
end if;

----如果还在待审核状态,不能做其他插入操作
select count(1)
into I_count
from task_flow_log
where task_info_id = :new.task_info_id --这句select报错
and state = 'T0';
if I_count > 0 then
raise data_unique_exception;
end if;


end TRG_TASK_FLOW_LOG;

这是我的insert语句。

insert into task_flow_log values ('AUTO',14776306,3,'08300002',sysdate,sysdate,1,5);

目前找到的解决方法是修改触发器,添加如下语句,但是这种做法可能会导致死锁。
PRAGMA AUTONOMOUS_TRANSACTION;

有没有高手还有更好的方法。
为什么web程序每天插都没事,我在plsql中插入一条就报这个错误呢。这个问题希望高手也能解答下。
...全文
评论 2
收藏 已收藏
分享
返回顶部