Re: Mutating tables
Date: 1996/01/12
Message-ID: <vEyLbEAYHp9wEwkt_at_jimsmith.demon.co.uk>#1/1
In article <4d51vg$br8_at_dns.plano.net>, Richard Long <rlong01_at_dallas.net>
writes
>I'm moving a system from sybase to oracle and am having some problems
>with triggers. I've followed the doc to set-up a trigger to set a key
>to -1 everytime the table is inserted. It no longer mutates but the
>update from the trigger does not take place. What is a good way to
>make this happen. Trigger follows:
>create OR REPLACE trigger tI_attachee
> after insert
> on attachee
> FOR EACH ROW
>DECLARE
> mutating_table EXCEPTION;
> PRAGMA EXCEPTION_INIT (mutating_table, -4091);
>begin
> update attachee
> set acu_stdld_key_i = -1
> where attachee.xtern_co_id_c = :old.xtern_co_id_c and
> attachee.attachee_cd_id_c = :old.attachee_cd_id_c;
>EXCEPTION
> WHEN mutating_table THEN
> null;
>end;
>/
>
>Thanks
>
The :old record does not exist for an insert, so your update will always
fail.
All you need to do is
:new.stdld_key_i:=-1 ;
-- Jim SmithReceived on Fri Jan 12 1996 - 00:00:00 CET