On Fri, 27 Oct 2000, Neil Davis wrote:
> 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.
> Neil P Davis
In response to
pgsql-general by date
|Next:||From: Tom Lane||Date: 2000-10-28 03:52:52|
|Subject: Re: newbie question: ERROR: getattproperties: no attribute tuple 1259 -2 |
|Previous:||From: Tom Lane||Date: 2000-10-28 02:42:30|
|Subject: Re: Selects in server side functions |