pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
RETURN QUERY documentation
2+ messages / 2 participants
[nested] [flat]

* RETURN QUERY documentation
@ 2013-04-23 06:37 Pavel Stehule <pavel.stehule@gmail.com>
  2013-04-24 02:51 ` Re: RETURN QUERY documentation Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 2+ messages in thread

From: Pavel Stehule @ 2013-04-23 06:37 UTC (permalink / raw)
  To: pgsql-docs; Erwin Brandstetter <brsaweda@gmail.com>; Peter Eisentraut <peter_e@gmx.net>

Hello

Here is patch for Erwin Brandstetter RETURN QUERY example

Regards

Pavel Stehule

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Attachments:

return_query_doc.patch (application/octet-stream, 1.1K) download diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 3b2b49d..9e61a20 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1733,6 +1733,38 @@ SELECT * FROM get_all_foo(); increasing this parameter. </para> </note> + + <para> + Here is an example of a function using <command>RETURN + QUERY</command>: + +<programlisting> +CREATE FUNCTION get_available_flightid(date) RETURNS SETOF integerAS +$BODY$ +BEGIN + RETURN QUERY SELECT flightid + FROM flight + WHERE flightdate >= $1 + AND flightdate < ($1 + 1); + + -- Since execution is not finished, we can check whether rows were returned + -- and raise exception if not. + IF NOT FOUND THEN + RAISE EXCEPTION'No flight at %.', $1; + END IF; + + RETURN; + END +$BODY$ +LANGUAGE plpgsql + +-- returns available flights or raise exception +-- if there are not available flight. +SELECT * FROM get_available_flightid(CURRENT_DATE); + +</programlisting> + + </para> </sect3> </sect2>
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: RETURN QUERY documentation
  2013-04-23 06:37 RETURN QUERY documentation Pavel Stehule <pavel.stehule@gmail.com>
@ 2013-04-24 02:51 ` Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2013-04-24 02:51 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: pgsql-docs; Erwin Brandstetter <brsaweda@gmail.com>

On Tue, 2013-04-23 at 08:37 +0200, Pavel Stehule wrote:
> Hello
> 
> Here is patch for Erwin Brandstetter RETURN QUERY example

Committed (after fixing several typos).




-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-04-24 02:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-04-23 06:37 RETURN QUERY documentation Pavel Stehule <pavel.stehule@gmail.com>
2013-04-24 02:51 ` Peter Eisentraut <peter_e@gmx.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox