ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [原创] 有关触发器 ORA-04091解决方法

[原创] 有关触发器 ORA-04091解决方法

原创 Linux操作系统 作者:yxyup 时间:2009-05-26 16:46:16 0 删除 编辑

YXYUP@dbatest>create table t_trigger(f1 number,f2 number,f3 number);

Table created.

YXYUP@dbatest>create or replace trigger test_trigger
  2    after update of f2 on t_trigger
  3    for each row
  4  BEGIN
  5    update t_trigger
  6       set f3 = 0
  7     where f1 = :new.f1 ;
  8  END;
  9  /

Trigger created.

Elapsed: 00:00:00.16

YXYUP@dbatest>
YXYUP@dbatest>insert into t_trigger values(1,1,1);

1 row created.

Elapsed: 00:00:00.01
YXYUP@dbatest>commit;

Commit complete.

Elapsed: 00:00:00.01
YXYUP@dbatest>select * from t_trigger;

        F1         F2         F3
---------- ---------- ----------
         1          1          1

Elapsed: 00:00:00.02
YXYUP@dbatest>
YXYUP@dbatest>
YXYUP@dbatest>update t_trigger set f2=0;
update t_trigger set f2=0
       *
ERROR at line 1:
ORA-04091: table YXYUP.T_TRIGGER is mutating, trigger/function may not see it
ORA-06512: at "YXYUP.TEST_TRIGGER", line 2
ORA-04088: error during execution of trigger 'YXYUP.TEST_TRIGGER'



YXYUP@dbatest>create or replace trigger test_trigger
  2    after update of f2 on t_trigger
  3    for each row
  4  BEGIN
  5     :new.f3:=0;  
  6  END;
  7  /
create or replace trigger test_trigger
                          *
ERROR at line 1:
ORA-04084: cannot change NEW values for this trigger type

YXYUP@dbatest>select * from t_trigger;

        F1         F2         F3
---------- ---------- ----------
         1          1          1

Elapsed: 00:00:00.01

YXYUP@dbatest>create or replace trigger test_trigger
  2    after update of f2 on t_trigger
  3    for each row
  4  BEGIN
  5     :new.f3:=0;  
  6  END;
  7  /
create or replace trigger test_trigger
                          *
ERROR at line 1:
ORA-04084: cannot change NEW values for this trigger type

YXYUP@dbatest>
YXYUP@dbatest>create or replace trigger test_trigger
  2    before update of f2 on t_trigger
  3    for each row
  4  BEGIN
  5     :new.f3 :=0;  
  6  END;
  7  /

Trigger created.

Elapsed: 00:00:00.04
YXYUP@dbatest>select * from t_trigger;

        F1         F2         F3
---------- ---------- ----------
         1          1          1

Elapsed: 00:00:00.01
YXYUP@dbatest>update t_trigger set f2=0;

1 row updated.

Elapsed: 00:00:00.00
YXYUP@dbatest>commit;

Commit complete.

Elapsed: 00:00:00.01
YXYUP@dbatest>select * from t_trigger;

        F1         F2         F3
---------- ---------- ----------
         1          0          0

Elapsed: 00:00:00.00
YXYUP@dbatest>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7364032/viewspace-604230/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-06

  • 博文量
    163
  • 访问量
    1320173