Re: Mutating tables

From: Robert C. Nix <rnix_at_us.oracle.com>
Date: 1996/01/12
Message-ID: <30F6D30D.71EA_at_us.oracle.com>#1/1


Richard Long wrote:
>
> 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
 

:old is ALWAYS null when inserting.
the reason it doesn't update is becuase the exception is fired which does nothing.

Try:

   :new.acu_stdld_key_i := -1;  

-- 
_________________________________________________
Robert C. Nix
Oracle Tools Support
rnix_at_us.oracle.com

DISCLAIMER:
The thoughts, opinions, remarks, suggestions, ...
expressed herein are my own and in no way should
be taken as a statement from Oracle Corporation.
Received on Fri Jan 12 1996 - 00:00:00 CET

Original text of this message