高手帮忙,oracle触发器问题
向表中插入数据时,表上有触发器,爆出如下错误:
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中插入一条就报这个错误呢。这个问题希望高手也能解答下。
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中插入一条就报这个错误呢。这个问题希望高手也能解答下。
...全文
相关推荐
关于oracle触发器before和after的应用问题
详细整理了oracle中before和after的使用问题
Oracle触发器表发生了变化 触发器不能读它的解决方法(必看)
下面小编就为大家带来一篇Oracle触发器表发生了变化 触发器不能读它的解决方法(必看)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Oracle_Trigger_及_Oracle_常见问题解决方法
Oracle_Trigger_及_Oracle_常见问题解决方法 Oracle_Trigger_及_Oracle_常见问题解决方法
oracle触发器详解
oracle触发器详解,对初步学习数据库的人有很大的帮助
oracle触发器调用存储过程
oracle 触发器 调用 存储过程 Oracle自治事务(Autonomous Transaction)


