Re: Update cascade on stmt, not on table definition

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: Felipenasc(at)aol(dot)com
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Update cascade on stmt, not on table definition
Date: 2003-02-06 14:58:41
Message-ID: 1044543521.22810.135.camel@camel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, 2003-02-06 at 07:22, Felipenasc(at)aol(dot)com wrote:
> Hi,
>
> I saw I can define a table that specifies a ON UPDATE CASCADE for a Foreign Key.
>
> I have a lot of tables with FK´s, and a lot of others with others FK's for the firts ones, and so on, and I haven´t defined the ON CASCADE clause on the FK´s tables.
> Now I need to update a primary key on the "mother" table.
>
> Is there a way to execute a stmt like 'update tbl set id_field=NEW_ID where id_field=OLD_ID on CASCADE', or something like that? Or do I need to redefine my tables, or the constraints?
>

There is no way to do this in an sql statement. You might be able to
modify the constraints to update instead of delete, though the syntax to
do this escapes me (perhaps someone else can post it?). Otherwise you'll
have to drop and recreate the fk triggers or recreate the table.

Robert Treat

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2003-02-06 15:05:59 Re: Duplicate indexes found in the postgres Database
Previous Message Robert Treat 2003-02-06 14:38:24 Re: