Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b4d7ea5

Browse files
committed
Add table creation and population to example
from John Gage
1 parent d017f83 commit b4d7ea5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

doc/src/sgml/xfunc.sgml

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.150 2010/07/25 08:30:42 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.151 2010/07/26 20:14:05 petere Exp $ -->
22

33
<sect1 id="xfunc">
44
<title>User-Defined Functions</title>
@@ -861,10 +861,23 @@ SELECT * FROM getfoo(1) AS t1;
861861
output parameters, like this:
862862

863863
<programlisting>
864+
CREATE TABLE tab (y int, z int);
865+
INSERT INTO tab VALUES (1, 2), (3, 4), (5, 6), (7, 8);
866+
864867
CREATE FUNCTION sum_n_product_with_tab (x int, OUT sum int, OUT product int)
865-
RETURNS SETOF record AS $$
868+
RETURNS SETOF record
869+
AS $$
866870
SELECT $1 + tab.y, $1 * tab.y FROM tab;
867871
$$ LANGUAGE SQL;
872+
873+
SELECT * FROM sum_n_product_with_tab(10);
874+
sum | product
875+
-----+---------
876+
11 | 10
877+
13 | 30
878+
15 | 50
879+
17 | 70
880+
(4 rows)
868881
</programlisting>
869882

870883
The key point here is that you must write <literal>RETURNS SETOF record</>

0 commit comments

Comments
 (0)