向表中插入数据时,表上有触发器,爆出如下错误:
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 SQL语句求助 oracle中table中默认存在emp,dept表,在这基础上询问
- 请教高手,在线等哈
- 怎配置oem使之用起来???
- 请问怎么在pl/sql里通过单步执行调试程序?
- [安装]一个非常详细的Oracle10.2在Red Hat Linux4 上的安装文档
- 8i里如何实现存储过程的嵌套调用?
- oracle里面一个用户怎么获得执行其它用户里面的过程的权限
- vc ado oracle update 无法更新,异常跳出,郁闷
- 这个sql怎么写?
- 如何给已经被锁的表解锁?
- 问个oracle默认查询排序问题
- oracle安装求助 error:/install/.oui: cannot execute binary file
PRAGMA AUTONOMOUS_TRANSACTION
是增加了一个内部的自治事务,原则上来说,不是太好,毕竟中间该提交的,该返回的,都做完了,外边的事务控制不了。
其实就楼主这个需求来讲,不用触发器,也比较容易实现,那就是,插入之前,去数据库select一次,看看。