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 -> trigger question

trigger question

From: Vincent Lemaire <v.Lemaire_at_kheops.com>
Date: 1999/06/09
Message-ID: <7jlkeh$gp4$1@minus.oleane.net>#1/1

Hi
(using Oracle 7.3)
I created a trigger called before update of a primary key. Here is the listing :

create or replace trigger t_pk before update of pk on master for each row begin
 update slave
 set slave.fk = :new.pk
 where slave.fk = :old.pk;
end;

this trigger is supposed to update the corresponding column of another table referencing this primary key, but that message appears : (translated from french)

SQLWKS> update master set pk = 2 where pk = 1;

ORA-04091: table VINCENT.MASTER in mutation, trigger/function can't see it
ORA-06512: in "VINCENT.T_PK", line 2
ORA-04088: error while execution of trigger 'VINCENT.T_PK'

I tried to disable the 'foreign key' constraint for the slave table : as I do this outside the trigger, it works, but an 'alter' statement is forbidden inside a trigger...

so my question is : how to automatically update a foreign key when the primary key referenced is updated ? Received on Wed Jun 09 1999 - 00:00:00 CDT

Original text of this message

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