pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: paallen@attglobal.net
Cc: pgsql-sql@postgresql.org
Subject: Re: Fw: How to FindNearest
Date: Tue, 3 Oct 2006 23:11:50 -0500
Message-ID: <20061004041150.GA30862@wolff.to> (raw)
In-Reply-To: <621614386-1159896983-cardhu_blackberry.rim.net-1477550429-@bxe017-cell01.bisx.prod.on.blackberry>
References: <621614386-1159896983-cardhu_blackberry.rim.net-1477550429-@bxe017-cell01.bisx.prod.on.blackberry>

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



view thread (6+ messages)

Message-ID: <20061004041150.GA30862@wolff.to>
Permalink:  ../20061004041150.GA30862@wolff.to/
Also on:    postgresql.org/message-id/20061004041150.GA30862@wolff.to

 · 

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: bruno@wolff.to, paallen@attglobal.net
  Subject: Re: Fw: How to FindNearest
  In-Reply-To: <20061004041150.GA30862@wolff.to>

* 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