Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E7B61633162 for ; Mon, 24 May 2010 14:00:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 42015-06 for ; Mon, 24 May 2010 17:00:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sargon.lncsa.com (mail.lncsa.com [213.215.28.11]) by mail.postgresql.org (Postfix) with ESMTP id BD30863249C for ; Mon, 24 May 2010 14:00:32 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 8A61D302541C for ; Mon, 24 May 2010 19:00:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bOPCnsdhIly6 for ; Mon, 24 May 2010 19:00:31 +0200 (CEST) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id 6CA4C3023121 for ; Mon, 24 May 2010 19:00:31 +0200 (CEST) Received: from delos.apartia.fr (delos.apartia.fr [10.0.3.107]) by zenon.apartia.fr (Postfix) with ESMTP id D4B4F5B8E2405 for ; Mon, 24 May 2010 19:00:30 +0200 (CEST) Received: by delos.apartia.fr (Postfix, from userid 1000) id 8942720283886; Mon, 24 May 2010 19:00:30 +0200 (CEST) Date: Mon, 24 May 2010 19:00:30 +0200 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: safely exchanging primary keys? Message-ID: <20100524170030.GB19481@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20100524085101.GA21249@apartia.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201005/108 X-Sequence-Number: 34156 On Mon, May 24, 2010 at 02:38:39PM +0000, Tim Landscheidt wrote: > Louis-David Mitterrand wrote: > > What does "are not properly updated" mean? Anyhow, why don't Hi, I did follow-up on my own post: the problem was elsewhere. > 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.