Skip site navigation (1) Skip section navigation (2)

Re: best way to swap two records (computer details)

From: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: best way to swap two records (computer details)
Date: 2005-03-23 17:28:58
Message-ID: 200503231728.58173.gary.stainburn@ringways.co.uk (view raw or flat)
Thread:
Lists: pgsql-sql
On Friday 18 March 2005 4:32 pm, you wrote:
> How about a user defined function ???
>
> CREATE OR REPLACE FUNCTION harwareupdate(integer, integer) RETURNS
> BOOLEAN AS '
>
>     update pieces set p_name = \'LSALES1\', p_location = \'Mike
> Haley\', p_site = \'L\' where p_id = $1;
>
>     update pieces set p_name = \'SPARE\', p_location = \'spare\',
> p_site = \'L\'
>     where p_id = 2;
>

This isn't quite what I want.  I want to SWAP the p_name and p_location 
between the two records, not set them to static values.

Any help would be appreciated.
-- 
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     


In response to

Responses

pgsql-sql by date

Next:From: Wei WengDate: 2005-03-23 17:37:54
Subject: How do I do this?
Previous:From: Gary StainburnDate: 2005-03-23 17:26:06
Subject: Re: best way to swap two records (computer details)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group