Re: Problem merging two rows into same primary key - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Problem merging two rows into same primary key
Date
Msg-id 20050523154714.GB12731@svana.org
Whole thread Raw
In response to Problem merging two rows into same primary key  (Patrik Kudo <kudo@pingpong.net>)
Responses Re: Problem merging two rows into same primary key
List pgsql-general
On Mon, May 23, 2005 at 04:40:12PM +0200, Patrik Kudo wrote:
> Hi!
>
> I've got a problem I can't seem to find an answer to. The problem is
> simplified by this example:
>
> 1. We have two tables:
>
> create table asdf (id serial primary key,
> data text);
> create table qwert (id serial,
> data integer references asdf
> on delete cascade on update cascade);

<snip>

> Now to the problem. We want to merge rows with id = 2 and id = 4 into id
> = 1 in the asdf table with the qwert table beeing updated to reflect the
> change. The desired result would yeild:

Why doesn't:

update quert set data = 1 where data = 2;
update quert set data = 1 where data = 4;
delete from asdf where id in (2,4);

work?

I thought update cascade only took effect when the primary key changed,
it updated referencing tables, not the other way round.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: C++-Language Function/Process List
Next
From: Tom Lane
Date:
Subject: Re: C++-Language Function/Process List