pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Long <mlong@datalong.com>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: best way to swap two records (computer details)
Date: Wed, 23 Mar 2005 12:59:45 -0500 (EST)
Message-ID: <52519.161.88.255.140.1111600785.squirrel@datalong.com> (raw)
In-Reply-To: <200503231728.58173.gary.stainburn@ringways.co.uk>
References: <200503181325.23293.gary.stainburn@ringways.co.uk>
	<d1evm7$2g5i$1@news.hub.org>
	<200503231728.58173.gary.stainburn@ringways.co.uk>

> 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.




view thread (7+ messages)  latest in thread

Message-ID: <52519.161.88.255.140.1111600785.squirrel@datalong.com>
Permalink:  ../52519.161.88.255.140.1111600785.squirrel@datalong.com/
Also on:    postgresql.org/message-id/52519.161.88.255.140.1111600785.squirrel@datalong.com

 · 

reply

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: mlong@datalong.com, gary.stainburn@ringways.co.uk
  Subject: Re: best way to swap two records (computer details)
  In-Reply-To: <52519.161.88.255.140.1111600785.squirrel@datalong.com>

* 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