Re: RETURN QUERY in PL/PgSQL?

From: "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: andrew(at)dunslane(dot)net, tgl(at)sss(dot)pgh(dot)pa(dot)us, neilc(at)samurai(dot)com, josh(at)agliodbs(dot)com
Subject: Re: RETURN QUERY in PL/PgSQL?
Date: 2007-04-24 05:58:32
Message-ID: BAY114-F32617B835D1C692C89B019F94A0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

It is RETURN TABLE(SQL) via ANSI SQL 2003

Table function support is in patch queue:
http://archives.postgresql.org/pgsql-patches/2007-02/msg00216.php
http://momjian.us/mhonarc/patches/msg00001.html

Regards
Pavel Stehule

>In a PL/PgSQL set-returning function, returning the result set of a
>query requires a FOR loop and repeated invocations of the RETURN NEXT
>statement:
>
> FOR x in SELECT ... LOOP
> RETURN NEXT x;
> END LOOP;
>
>This works, but it seems overly verbose. It occurred to me that we could
>easily add a new PL/PgSQL statement that evaluates a set-returning
>expression and adds *all* the resulting rows to the function's result
>set. For example:
>
> RETURN QUERY SELECT ...;
>
>I'm not sure of the right name: "RETURN ROWS" or "RETURN ALL" might also
>work. Of course, this is syntax sugar (and superficial sugar at that),
>but I believe this is a fairly common requirement.

_________________________________________________________________
Citite se osamele? Poznejte nekoho vyjmecneho diky Match.com.
http://www.msn.cz/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2007-04-24 06:00:00 Re: RETURN QUERY in PL/PgSQL?
Previous Message Magnus Hagander 2007-04-24 05:32:08 Re: [HACKERS] Wild idea: 9.0?