Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 940DF9FB3F7 for ; Wed, 4 Oct 2006 01:01:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 74617-03 for ; Wed, 4 Oct 2006 04:01:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id A22929FB3EF for ; Wed, 4 Oct 2006 01:01:33 -0300 (ADT) Received: (qmail 31535 invoked by uid 500); 4 Oct 2006 04:11:50 -0000 Date: Tue, 3 Oct 2006 23:11:50 -0500 From: Bruno Wolff III To: paallen@attglobal.net Cc: pgsql-sql@postgresql.org Subject: Re: Fw: How to FindNearest Message-ID: <20061004041150.GA30862@wolff.to> Mail-Followup-To: Bruno Wolff III , paallen@attglobal.net, pgsql-sql@postgresql.org References: <621614386-1159896983-cardhu_blackberry.rim.net-1477550429-@bxe017-cell01.bisx.prod.on.blackberry> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <621614386-1159896983-cardhu_blackberry.rim.net-1477550429-@bxe017-cell01.bisx.prod.on.blackberry> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/33 X-Sequence-Number: 26422 On Tue, Oct 03, 2006 at 17:35:55 +0000, paallen@attglobal.net wrote: > > My function will take all the above info about the hole and down_hole_survey tables, and sample.hole_id and sample.depth_meters and will calculate the coordinates. I need to put these coordinates into sample.x , sample.y and sample.z . > > What I used to do was have one function that would return 3 values (x,y,z). Then create 3 more functions that would call call the main function and pull out the 3 values seperately to update the 3 seperate columns. It works fine but I have to call the main function 3 times which produces a slow performance. > > I hope that I explained it better this time. If they are in the same table you can update all there in the same update statement using syntax something like the following: UPDATE sample SET x=(some expression), y=(some expression), z=(some expression) WHERE some condition; Probably the simplest place to start is having your function do the update rather than return the three values. I think in 8.2 there will be an easier way to use the result of a function that returns a row to update multiple columns in an update statement. (That doesn't resu;t in calling the function three times.)