Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Avoiding recursive triggering
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 Received on Wed Dec 08 1999 - 07:13:30 CST