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')
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