Re: trigger error - mutating table???

From: Michael Krolewski <vandra_at_u.washington.edu>
Date: Wed, 26 Aug 1998 00:08:20 -0700
Message-ID: <35E3B464.94BC3BAA_at_u.washington.edu>


I believe you want a BEFORE INSERT trigger. Same code Before insert is during the insert process but just prior to the insert of the record. After insert is generally used to update other tables.

Mike Krolewski

Vanessa McCauley wrote:

> I am trying to construct a very simple trigger AFTER INSERT of a parent
> record, to populate the child record's FK field.....
> On INSERT to FACILITIES, the application first generates a random surrogate
> PK in the REGISTRY table, then returns that value to act as the
> FACILITIES.PK value as well. All good.
> So, the trigger takes that PK value from FACILITIES, and kicks it back to
> the REGISTRY record's FK to FACILITIES. This has to happen AFTER INSERT,
> since the REGISTRY record is formally a child of the FACILITIES record.
> Hence:
> CREATE TRIGGER.....
> AFTER INSERT ON F_FACILITIES
> BEGIN
> INSERT INTO REGISTRY (FKEY_FACILITIES)
> VALUES (:NEW.PKEY)
> WHERE REGISTRY.PKEY = :NEW.PKEY;
> END;
> The error message states "f_facilities is mutating, the trigger may not see
> it..."
> I cannot find a discussion of mutating tables (or even a definition) in any
> on-line ORACLE books, O'Reilly press books, or Oracle press books that I
> have. Any ideas?
> Thanks!
> -Veeb
Received on Wed Aug 26 1998 - 09:08:20 CEST

Original text of this message