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_at_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)

  • mcs
Received on Wed Feb 18 2004 - 03:02:56 CET

Original text of this message