Re: Selects in server side functions

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Neil Davis <npdavis(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Selects in server side functions
Date: 2000-10-28 03:36:58
Message-ID: Pine.BSO.4.10.10010272330420.2291-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 27 Oct 2000, Neil Davis wrote:

> Hello,
> I am trying to figure out how to return more than one field using "SETOF".
SETOF is to return more than one record, not more than one field. Also,
SETOF is only currently working for SQL language functions.

What you probably need is following:
create procedure x returns foo ....

and create a table foo with list of fields you want to return.

That will work IFF you are not calling this function directly from the
client, but are accessing it from plpgsql code. If you are accessing it
from a client, it won't work. I don't know what will :)

> I can concatenate the fields in the select statement down to one and use SETOF Text to return them, then split them back apart in my code. This is a bit kludgy though. I would rather do this correctly and efficiently. In most RDBMS you can easily deal with multiple columns in server side procedures that contain a SELECT, but I can find nothing about how to do this in PostGreSQL Documentation or anywhere else.
>
> How can you do this with PostGreSQL? If you can, is it better to do this this way, or better to put the query inline in the code?
>
> Please respond to the email at the bottom.
>
> thx,
> Neil P Davis
> npdavis(at)hotmail(dot)com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-10-28 03:52:52 Re: newbie question: ERROR: getattproperties: no attribute tuple 1259 -2
Previous Message Tom Lane 2000-10-28 02:42:30 Re: Selects in server side functions