Re: Mutating Tables Ans Triggers

From: Bob Wall <wall_at_nospam_montanadsl.net>
Date: Mon, 09 Jul 2001 15:09:19 -0600
Message-ID: <3B4A1D7F.B5909E8_at_nospam_montanadsl.net>


   I believe there is a way to do this - say you have the table

CREATE TABLE a (

   b NUMBER(8),
   c NUMBER(8));

CREATE OR REPLACE TRIGGER tab_a_trg
BEFORE UPDATE ON a
FOR EACH ROW
BEGIN
   IF (:new.b <> :old.b)
   THEN

      :new.c := :old.c + 1;
   END IF;                                           
END;                                                 


   "old" and "new" are predefined in the trigger - each has the type of a row of the table, and you are free to update the values in "new".

   I am not sure with which version of Oracle this was introduced - I know it works this way in 8.1.7, and I think it was probably there in 8.1.6.

Later,
Bob Wall
AWI, Inc.

Sybrand Bakker wrote:
>
> "Xmina" <xmina_leiria_at_clix.pt> wrote in message
> news:lV7W6.6152$Aw6.21577869_at_newsserver.ip.pt...
> >
> > We Arrived To a Very Bad Situation.
> >
> > We Hava Mutating Tables when we have Triggers that must update them,
 The
> > creation of the Triggers are well done however when we try to update that
> > tables we btain the dollowing error:
> >
> > ORA-04091: tabela SCOTT.HORA_EXTRA está em mutação, trigger não a pode
> > ler ou modificar
> > ORA-06512: na "SCOTT.F_HORA_EXTRA", linha 6
> > ORA-06512: na linha 1
> > ORA-06512: na "SCOTT.T_HORA_EXTRA_0", linha 8
> > ORA-04088: erro durante a execução do trigger 'SCOTT.T_HORA_EXTRA_0'
> >
> > We obtain the Famous Error ORA-04091. For What we investigated we can
 do
> > the update using not one trigger but three triggers using PACKAGES, but
 for
> > a newbie that is a little bit complicated .
> >
> > IS There any solution more simple ???
> >
> > Can You Answer me please ???
> >
> > xmina_leiria_at_clix.pt
> >
> >
> >
> >
>
> There isn't.
>
> Regards,
>
> Sybrand Bakker, Oracle DBA
Received on Mon Jul 09 2001 - 23:09:19 CEST

Original text of this message