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

From: "Michael Long" <mlong(at)datalong(dot)com>
To: "Gary Stainburn" <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: best way to swap two records (computer details)
Date: 2005-03-23 17:59:45
Message-ID: 52519.161.88.255.140.1111600785.squirrel@datalong.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
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;
>>
>

Why not declare variables and select the current values into them and then update
the records with the appropriate values.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2005-03-23 18:52:35 Re: [despammed] How do I do this?
Previous Message Wei Weng 2005-03-23 17:37:54 How do I do this?