Re: Mutating table error

From: VC <boston103_at_hotmail.com>
Date: Tue, 17 Feb 2004 23:58:06 GMT
Message-ID: <iUxYb.208484$U%5.1156019_at_attbi_s03>


Hello,

In

create or replace trigger test_Trigger
 after update on mvkTest
 for each row
 begin update mvkTest
 set kogda = sysdate;
 end;

... you are trying to update a table which is in the process of being changed by the triggering statement and this causes the 'mutating' error. For a discussion, see
http://asktom.oracle.com/pls/ask/f?p=4950:8:7998628199372151219::NO::F4950_P 8_DISPLAYID,F4950_P8_CRITERIA:9579487119866, In your case, it's unclear why you need a trigger at all since you can just use the default of 'SYSDATE' on the column in question...

VC

"M" <greenandkind_at_yahoo.com> wrote in message news:c7b3da1b.0402171142.639944cb_at_posting.google.com...
> Hello,
>
> I have a very simple table, and want to create a trigger that updates
> the date column entry (with the current date), whenever a row gets
> modified.
> Is there a simple way of fixing this, or would I have to create 3
> extra triggers, a package, etc., as described in most posts about
> mutating table errors?
> Could you please explain to me WHY this error happens here (I have not
> been able to find a clear explanation of what causes them)?
>
>
> create table mvkTest
> (bukva char(5),
> kogda date);
>
> insert into mvkTest
> values('aaa', sysdate);
> insert into mvkTest
> values('bbb', sysdate);
>
> create or replace trigger test_Trigger
> after update on mvkTest
> for each row
> begin update mvkTest
> set kogda = sysdate;
> end;
> /
>
> update mvkTest
> set bukva = 'ccc'
> where bukva = 'aaa';
>
> =======>>>>>>
>
> update mvkTest
> *
> ERROR at line 1:
> ORA-04091: table DTI.MVKTEST is mutating, trigger/function may not see
> it
> ORA-06512: at "DTI.TEST_TRIGGER", line 1
> ORA-04088: error during execution of trigger 'DTI.TEST_TRIGGER'
>
>
>
> Thank you,
> G.
Received on Wed Feb 18 2004 - 00:58:06 CET

Original text of this message