diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2010-07-26 20:14:05 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2010-07-26 20:14:05 +0000 |
commit | b4d7ea5f6e3cce29b0ba4a373d3a36aa2542d86b (patch) | |
tree | d5e8aa3b0018fff866b7e3dd55c2b186ac977a67 /doc/src | |
parent | d017f8359c863ff4064f3fdb66aa07d4dcf380c9 (diff) | |
download | postgresql-b4d7ea5f6e3cce29b0ba4a373d3a36aa2542d86b.tar.gz postgresql-b4d7ea5f6e3cce29b0ba4a373d3a36aa2542d86b.zip |
Add table creation and population to example
from John Gage
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/xfunc.sgml | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index fcbf6407298..93bdf572f37 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.150 2010/07/25 08:30:42 petere Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.151 2010/07/26 20:14:05 petere Exp $ --> <sect1 id="xfunc"> <title>User-Defined Functions</title> @@ -861,10 +861,23 @@ SELECT * FROM getfoo(1) AS t1; output parameters, like this: <programlisting> +CREATE TABLE tab (y int, z int); +INSERT INTO tab VALUES (1, 2), (3, 4), (5, 6), (7, 8); + CREATE FUNCTION sum_n_product_with_tab (x int, OUT sum int, OUT product int) -RETURNS SETOF record AS $$ +RETURNS SETOF record +AS $$ SELECT $1 + tab.y, $1 * tab.y FROM tab; $$ LANGUAGE SQL; + +SELECT * FROM sum_n_product_with_tab(10); + sum | product +-----+--------- + 11 | 10 + 13 | 30 + 15 | 50 + 17 | 70 +(4 rows) </programlisting> The key point here is that you must write <literal>RETURNS SETOF record</> |