Re: best way to swap two records (computer details) - Mailing list pgsql-sql

From PFC
Subject Re: best way to swap two records (computer details)
Date
Msg-id op.snumxjkpth1vuj@localhost
Whole thread Raw
In response to best way to swap two records (computer details)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Responses Re: best way to swap two records (computer details)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
> 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')



pgsql-sql by date:

Previous
From: lucas@presserv.org
Date:
Subject: Trigger with parameters
Next
From: Leon Stringer
Date:
Subject: Re: Consecutive row count query