Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Cascading Update Triggers

Re: Cascading Update Triggers

From: <andreas.prusch_at_sintec.de>
Date: Thu, 28 May 1998 07:11:31 GMT
Message-ID: <6kj2n2$5ro$1@nnrp1.dejanews.com>


This problem occurs because there are enabled foreign key constraints on the child table. If there are disabled the following solution works:

fk = foreign key
pk = primary key

create or replace trigger change_pk
before update on parent
for each row
declare
  cursor c_child(pk parent.pk%type) is select 'x' from child for update;   new_pk parent.pk%type;
begin
  new_pk := function_which_determine_new_pk;   :new.pk := new_pk;
  for dummy in c_child(new_pk) loop
    update child set fk = new_pk where current of c_child;   end loop;
end;

But, I think you already know this.
Andreas Prusch

In article <6kh458$3th$1_at_nnrp1.dejanews.com>,   mike_andrew_at_usiva.com wrote:
>
> I am gettting a mutating table error when I try to update the primary key in
> the parent table with enabled after update cascading triggers.Is there a
> standard way to write this trigger, based on one parent and one child??
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Thu May 28 1998 - 02:11:31 CDT

Original text of this message

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