Re: ora-04091, updating same table in trigger

From: Nigel Thomas <nigel.cl.thomas_at_googlemail.com>
Date: Mon, 20 Apr 2009 16:45:04 +0100
Message-ID: <53258cd50904200845r1d529a64icc3a566c0cfbb2a5_at_mail.gmail.com>



Harvinder

Rather than updating the row, use a BEFORE ROW trigger simply to set the column value in the trigger - it will get applied when the update is processed. See examples in docs, eg:

CREATE OR REPLACE TRIGGER emp_sal_trg
BEFORE UPDATE ON emp
FOR EACH ROW
BEGIN
  IF :NEW.Comm IS NULL and :NEW.Job = 'SALES' THEN    :New.Comm := :New.Sal * 0.1;
  END IF;
END; (docs for 9iR2 :15 Using
Triggers<http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg13trg.htm#376> )

Regards Nigel

2009/4/20 Harvinder Singh <Harvinder_Singh_at_picis.com>

> Hi,
>
> Currently insert into a table is failing with error ora-04091 and it
> looks like after-row insert/update trigger is trying to update the same
> table, for example if we try to insert row into table and 1 column is
> empty then in trigger based on some logic we update that column for same
> row.
> How can we fix this issue, Is there any workaround so that we can update
> the same table in the trigger?
>
> Thanks
> --Harvinder
>
>
>
>
> The information in this email is confidential and may be legally
> privileged. It is intended solely for the addressee. Access or use by any
> other person to this internet email is not authorized and may be unlawful.
> If you are not the intended recipient, please delete or destroy this email.
> If you do not wish to receive future emails from this sender, please reply
> directly to this email requesting you be removed from any mailing list.
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Apr 20 2009 - 10:45:04 CDT

Original text of this message