X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 90A5753584 for ; Wed, 23 Mar 2005 17:59:56 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69351-03 for ; Wed, 23 Mar 2005 17:59:49 +0000 (GMT) Received: from server18.pronicsolutions.com (server18.pronicsolutions.com [66.103.131.81]) by svr1.postgresql.org (Postfix) with ESMTP id 390AD5335D for ; Wed, 23 Mar 2005 17:59:48 +0000 (GMT) Received: from datalong by server18.pronicsolutions.com with local (Exim 4.44) id 1DEA8v-0001F8-Dg; Wed, 23 Mar 2005 12:59:45 -0500 Received: from 161.88.255.140 ([161.88.255.140]) (SquirrelMail authenticated user mlong@datalong.com) by datalong.com with HTTP; Wed, 23 Mar 2005 12:59:45 -0500 (EST) Message-ID: <52519.161.88.255.140.1111600785.squirrel@datalong.com> In-Reply-To: <200503231728.58173.gary.stainburn@ringways.co.uk> References: <200503181325.23293.gary.stainburn@ringways.co.uk> <200503231728.58173.gary.stainburn@ringways.co.uk> Date: Wed, 23 Mar 2005 12:59:45 -0500 (EST) Subject: Re: best way to swap two records (computer details) From: "Michael Long" To: "Gary Stainburn" Cc: pgsql-sql@postgresql.org Reply-To: mlong@datalong.com User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server18.pronicsolutions.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [32026 527] / [47 12] X-AntiAbuse: Sender Address Domain - datalong.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/317 X-Sequence-Number: 20796 > 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.