[postgis-users] Returning multiple fields from a plpgsql function
David William Bitner
david.bitner at gmail.com
Wed Jul 29 15:25:10 PDT 2009
Off the top of my head I believe you would do select (myfunc()).*
or (func()).attr1,...
On Wed, Jul 29, 2009 at 1:19 PM, Stephen Woodbridge <woodbri at swoodbridge.com
> wrote:
> Hi,
>
> This is another slightly off topic, but maybe generally helpful inquiry.
>
> I have a plpgsql function the does some spatial queries and returns results
> using a type like:
>
> CREATE TYPE my_result AS
> (attr1 text,
> attr2 text,
> attr3 text,
> distance float,
> linkid int);
>
>
> in the function:
>
> DECLARE
> ret my_result;
>
> then set the values of the fields like:
>
> ret.attr1 := attr1;
> ...
>
> and return the results like:
>
> return ret;
>
>
> later I do:
>
> select my_function(x,y);
>
> and get a result that looks like:
>
> ("attr1","attr2","attr3",102.2,1234567)
>
> which all looks fine and dandy, except that I can not seem to access the
> individual fields. So for example if I want the value of my_result.attr1 how
> would I get that? Is there a better way to do this?
>
> Thanks,
> -Steve
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
--
************************************
David William Bitner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090729/705ce0b6/attachment.html>
More information about the postgis-users
mailing list