Re: safely exchanging primary keys?

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: safely exchanging primary keys?
Date: 2010-05-25 01:22:46
Message-ID: m3r5l0zsex.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michele Petrazzo - Unipex 2010-05-26 17:34:56 inner join and limit
Previous Message Joshua Tolley 2010-05-24 22:14:45 Re: User function that returns a set of rows.