Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Trigger problem

Trigger problem

From: Michael Zhao <mizhao_at_cisco.com>
Date: Mon, 11 Mar 2002 12:30:16 -0800
Message-ID: <1015878418.289669@sj-nntpcache-5>


Hi,

I have very simple table "t1" in Oracle 8.1.7 database, I wrote a trigger on "t1" and got an error when I update "t1".

ORA-04091: table T1 is mutating, trigger/function may not see it
ORA-06512: at "AU_T1", line 4
ORA-04088: error during execution of trigger AU_T1'

But the same trigger works fine in Sybase.

How can I write this trigger so I can "select" or "update" other rows in the same table in my trigger?

Thanks in advance.

-Michael

====Table====

create table t1 (
tid number(10) primary key,
name varchar2(40)
);

====Trigger====

create or replace trigger au_t1
before insert or update
on t1
referencing old as old new as new
for each row
declare

    cc number(10);
begin
 select count(tid) into cc from t1;
end;
/

====Update====

update t1 set tid=2 where tid=1; Received on Mon Mar 11 2002 - 14:30:16 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US