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: Avoiding recursive triggering

Re: Avoiding recursive triggering

From: Morten Primdahl <morten_at_caput.com>
Date: Thu, 09 Dec 1999 10:03:49 +0100
Message-ID: <384F7075.348FD4A@caput.com>

Thanks to both of you. I wonder when I'll learn to not miss the obvious ;)

Morten

Thomas Kyte wrote:
>
> A copy of this was sent to Morten Primdahl <morten_at_caput.com>
> (if that email address didn't require changing)
> On Wed, 08 Dec 1999 11:34:32 +0100, you wrote:
>
> >
> >Howdy.
> >
> >Is there a way I can avoid recursive triggering?
> >
> >CREATE OR REPLACE TRIGGER upd_trg_table
> >AFTER UPDATE ON table
> >FOR EACH ROW
> >BEGIN
> > UPDATE table SET date_changed = (SELECT ROUND(SYSDATE) FROM DUAL)
> > WHERE id = :old.id;
> >END;
> >
> >I haven't tested the above trigger, but it looks
> >recursive to me. Is there some standard way to avoid
> >a such recursion?
>
> it'll get a mutating table error before it recurses.
>
> you want to code simply:
>
> create or replace trigger upd_trg_table
> BEFORE update on table for each row
> begin
> :new.date_changed := round(sysdate);
> end;
>
> just change the :new variables in a BEFORE row trigger to effect the update.
>
> >
> >Thanks,
> >
> >Morten
>
> --
> See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
> Current article is "Part I of V, Autonomous Transactions" updated June 21'st
>
> Thomas Kyte tkyte_at_us.oracle.com
> Oracle Service Industries Reston, VA USA
>
> Opinions are mine and do not necessarily reflect those of Oracle Corporation

--

Morten Primdahl		Caput ApS	Tel +45 33 12 24 42		
morten_at_caput.com	Nygade 6	Fax +45 33 91 24 42
http://www.caput.com	DK-1164 Kbh K
Received on Thu Dec 09 1999 - 03:03:49 CST

Original text of this message

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