Re: Problem merging two rows into same primary key

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Problem merging two rows into same primary key
Дата
Msg-id 20050523154714.GB12731@svana.org
обсуждение исходный текст
Ответ на Problem merging two rows into same primary key  (Patrik Kudo <kudo@pingpong.net>)
Ответы Re: Problem merging two rows into same primary key  (Patrik Kudo <kudo@pingpong.net>)
Список 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.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: C++-Language Function/Process List
Следующее
От: Tom Lane
Дата:
Сообщение: Re: C++-Language Function/Process List