Re: safely exchanging primary keys? - Mailing list pgsql-sql

From Tim Landscheidt
Subject Re: safely exchanging primary keys?
Date
Msg-id m3r5l0zsex.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to safely exchanging primary keys?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
List pgsql-sql
Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org> wrote:

>> > you use something simple like (untested):
>> >
>> > | UPDATE cabin_type
>> > |   SET id_cabin_type =
>> > |     CASE
>> > |       WHEN id_cabin_type = id1 THEN
>> > |         id2
>> > |       ELSE
>> > |         id1
>> > |     END
>> > |   WHERE id_cabin_type IN (id1, id2);

>> Nice, thanks.

> Ah, but this won't work as the UNIQUE PK constraint is in force.

Oh, yes, you're right, I didn't have that premise in mind.

Tim



pgsql-sql by date:

Previous
From: Joshua Tolley
Date:
Subject: Re: User function that returns a set of rows.
Next
From: Michele Petrazzo - Unipex
Date:
Subject: inner join and limit