Re: Mutating table error

From: VC <boston103_at_hotmail.com>
Date: Wed, 18 Feb 2004 03:39:25 GMT
Message-ID: <M7BYb.348835$na.516061_at_attbi_s04>


Hello,

"Mark C. Stock" <mcstockX_at_Xenquery .com> wrote in message news: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
>

Agree. I missed the update part ;)

> 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 - 04:39:25 CET

Original text of this message