Re: RETURN QUERY in PL/PgSQL? - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: RETURN QUERY in PL/PgSQL?
Date
Msg-id BAY114-F32617B835D1C692C89B019F94A0@phx.gbl
Whole thread Raw
In response to RETURN QUERY in PL/PgSQL?  (Neil Conway <neilc@samurai.com>)
Responses Re: RETURN QUERY in PL/PgSQL?  (Neil Conway <neilc@samurai.com>)
List 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/



pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: RETURN QUERY in PL/PgSQL?
Next
From: Tom Lane
Date:
Subject: Re: RETURN QUERY in PL/PgSQL?