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 -> help with mutating table

help with mutating table

From: <grey1969_at_my-dejanews.com>
Date: Tue, 05 Jan 1999 23:46:45 GMT
Message-ID: <76u895$359$1@nnrp1.dejanews.com>


I'm fairly new to Oracle, and I'm having a problem figuring out how to get around a mutating table. I have a before insert trigger that gets the primary key for the parent table:

    select client_seq.nextval into v_client_id from dual;     :new.client_id := v_client_id;

Then I have an after insert trigger on the same table that uses the new client_id and tries to insert it into a child table:

   insert into logic_table
   (Client_id, flag_value)
   select :new.client_id, -1 from some_table;

The after insert trigger fails because of mutating. There's a foreign key on logic_table.Client_id. The trigger works if I remove the foreign key constraint.

I thought that the insert had taken place by the time the after insert trigger fires. Why isn't the client_id available for the insert?

Aside from removing the constraint, how can I insert a record into the child table (logic_table) from a trigger?

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Jan 05 1999 - 17:46:45 CST

Original text of this message

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