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

Home -> Community -> Usenet -> comp.databases.oracle -> Re: Mutating table error

Re: Mutating table error

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Tue, 17 Feb 2004 21:02:56 -0500
Message-ID: <UeqdnSRUc4SVVa_dRVn_iw@comcast.com>

"VC" <boston103_at_hotmail.com> wrote in message news: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
|

actually, there are two issues with using a default value instead of a trigger

  1. it can be overridden on INSERT (including with an explicit null)
  2. it only works on INSERT, not on UPDATE

a trigger is the only way to guarantee that a value is set, outside of limiting all access to an API (for which there are many valid arguments)

Received on Tue Feb 17 2004 - 20:02:56 CST

Original text of this message

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