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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Avoding Mutation of Table trigger

RE: Avoding Mutation of Table trigger

From: Richard Huntley <rhuntley_at_mindleaders.com>
Date: Thu, 22 Aug 2002 12:56:13 -0800
Message-ID: <F001.004BD7F6.20020822125613@fatcity.com>


Naba,

The solution for ORA-4091 is to create two triggers--a row level (before insert or update)
and a statement level (after insert or update). In the row level you simply record the values of :new.AMT
into a PL/SQL table. Then in the statement level trigger you perform the calculation based on the
recorded values in the PL/SQL table. Record the values using a PL/SQL table in a "package",
that way you won't have to worry about simultaneous updates by different sessions.

HTH,
Rich

-----Original Message-----
Sent: Tuesday, August 20, 2002 4:28 AM
To: Multiple recipients of list ORACLE-L

Hi,

    This problem/solution may be posted earlier, but would like to hear     a solution from you.

I have two table say TAB1 and TAB2. TAB2 is a detail of TAB1 table.

  1. TAB1 Pk_key numnber(10) AMT numnber(14,2) ... More colums pk_key is Primary Key.
  2. TAB2 Pk_key numnber(10) PK_sl number(2) AMT numnber(14,2) ... More colums
  3. pk_key + pk_sl is Primary Key.
  4. pk_key is foreign key to tab1

Now I would like to write a trigger in TAB2 for INSERT and UPDATE operation which will update the AMT coloum of TAB1. The value to be updated is sum of AMT coloumn of TAB2 for the PK_KEY value.

    i.e. select sum(amt) into tot from TAB2 where PK_KEY= :NEW.PK_KEY;

Since TAB2 is currently being modified it can not be read.

so, how to solve it ?

TIA Regards.

Naba

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: N J Neog
  INET: njneog_at_oil.asm.nic.in

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Richard Huntley
  INET: rhuntley_at_mindleaders.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Aug 22 2002 - 15:56:13 CDT

Original text of this message

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