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

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL: Mutating Table

Re: PL/SQL: Mutating Table

From: <Christer.XK.Andersson_at_trab.se>
Date: 1997/03/20
Message-ID: <33315B45.40F0@trab.se>#1/1

My guess is:
When you insert a new record into table B and B has a foreign key to another table A, table B makes a select in table A to see that the parent exists. Table A better not be mutating when this select is made.

This could be the reason to why your trigger does not work (the hidden select that arttrans makes on article).

Tip of the day: Remove the foreign key and never create it again, cause do you really need it? Or create a package which stores the :old.an and :old.prinit in PL/SQL-tables. In your current trigger you instead of the insert statement, make a call to a procedure in the package which stores the values in the PL/SQL-tables. You then create another after update trigger without the for each row option, the advantage of this trigger is that the article table is not mutating any longer, so it's ok to now insert the data into arttrans.

This is perhaps not clear enough and if so, let me know :-).

/br Christer Andersson!

Valentin Maier wrote:
>
> >
> > The mutating table error is due to an attempt to update a row in another
> > table that has a foreign key relationship to the table on which the
> > trigger is located. In your case, you probably have a foreign key between
> > ARTICLE and ARTTRANS.
> >
> > Dan
>
> Dan,
>
> Thank you for your answer. You are right, I have a foreign key between ARTICLE and ARTTRANS but as you can see
> from the above code, I do not modify any foreign key in ARTTRANS, I just insert a new record in this table (it
> is a kind of audit that I modified something in ARTICLe table).
>
> I would appreciate any further help.
>
> TIA,
>
> Valentin.
Received on Thu Mar 20 1997 - 00:00:00 CST

Original text of this message

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