Index: doc/src/sgml/plpgsql.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v retrieving revision 1.55 diff -c -r1.55 plpgsql.sgml *** doc/src/sgml/plpgsql.sgml 8 Jan 2005 22:13:34 -0000 1.55 --- doc/src/sgml/plpgsql.sgml 13 Jan 2005 17:21:19 -0000 *************** *** 2306,2311 **** --- 2306,2339 ---- COMMIT; + + + The following example lets you return multiple cursors from a + single function. + + + CREATE OR REPLACE FUNCTION myfunc(refcursor, refcursor) + RETURNS SETOF refcursor + LANGUAGE plpgsql + AS $$ + BEGIN + OPEN $1 FOR SELECT 1; + RETURN NEXT $1; + OPEN $2 FOR SELECT 2; + RETURN NEXT $2; + RETURN; + END; + $$; + + -- need to be in a transaction to use cursors. + BEGIN; + + SELECT * FROM myfunc('a', 'b'); + + FETCH ALL FROM a; + FETCH ALL FROM b; + +