From: | Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> |
---|---|
To: | "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: best way to swap two records (computer details) |
Date: | 2005-03-23 17:26:06 |
Message-ID: | 200503231726.06583.gary.stainburn@ringways.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Friday 18 March 2005 7:54 pm, you wrote:
> > 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')
Hello again.
I've tried the first one but get a syntax error. Anyone see why?
hardware=# update pieces set p_owner = (case if p_owner = 305 then 724
else 305 end) where p_owner in (305, 724);
ERROR: parser: parse error at or near "p_owner"
hardware=#
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
From | Date | Subject | |
---|---|---|---|
Next Message | Gary Stainburn | 2005-03-23 17:28:58 | Re: best way to swap two records (computer details) |
Previous Message | Sean Davis | 2005-03-23 11:04:04 | Re: Self-referencing table question |