Re: SETOF and language 'plpgsql' - Mailing list pgsql-general

From Tom Lane
Subject Re: SETOF and language 'plpgsql'
Date
Msg-id 3083.1004823761@sss.pgh.pa.us
Whole thread Raw
In response to Re: SETOF and language 'plpgsql'  ("Eric Ridge" <ebr@tcdi.com>)
List pgsql-general
"Eric Ridge" <ebr@tcdi.com> writes:
>> How do you return a "setof <datatype>" from a plpgsql function?

> After searching the archives I found a post by Jan Wieck that basically
> says, "You can't....not sure if we will be able to  do  it  for  7.2".
> Then Tom Lane replied, "...If you want to fix plpgsql so that it retains
> state and can produce multiple elements of a set over repeated calls,
> the same way that SQL functions do, then it could be done today."

I think you misread that ;-).  What I was saying was that there wasn't
(any longer) anything outside plpgsql that would prevent it from
returning sets.  There would be a nontrivial amount of work to do inside
plpgsql to make it happen; see Jan's followup
http://archives2.us.postgresql.org/pgsql-sql/2000-08/msg00258.php

> It's over a year later.  What's the status today?

About the same.

There is support in 7.2 for plpgsql functions to return references to
cursors. This is not by any means the same thing as a SETOF result,
but it can serve some of the same purposes.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: CREATE TYPE delimiter?
Next
From: "Oliver Elphick"
Date:
Subject: Re: Off-Topic: Accounting question