pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: best way to swap two records (computer details)
Date: Fri, 18 Mar 2005 20:54:45 +0100
Message-ID: <op.snumxjkpth1vuj@localhost> (raw)
In-Reply-To: <200503181325.23293.gary.stainburn@ringways.co.uk>
References: <200503181325.23293.gary.stainburn@ringways.co.uk>


> My question is what's the best way to swap settings between the two
> computer records and swap any software installed?  Ideally I'd like it
> in the form of a function where I can pass the two p_id's and return a
> boolean reflecting success (true) or fail (false).


	I'd say something like that (generic table names) :

If you're confident :
UPDATE stuff SET owner = (CASE IF owner='A' THEN 'B' ELSE 'A' END) WHERE  
owner IN ('A','B')

If you're paranoid :
UPDATE stuff SET owner = (CASE IF owner='A' THEN 'B' ELSE IF owner='B'  
THEN 'A' ELSE owner END) WHERE owner IN ('A','B')




view thread (7+ messages)  latest in thread

Message-ID: <op.snumxjkpth1vuj@localhost>
Permalink:  ../op.snumxjkpth1vuj@localhost/
Also on:    postgresql.org/message-id/op.snumxjkpth1vuj@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@boutiquenumerique.com, gary.stainburn@ringways.co.uk
  Subject: Re: best way to swap two records (computer details)
  In-Reply-To: <op.snumxjkpth1vuj@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox