From 663aabaa6e1c07c376b666f34bb5eb1fc9b2b3fe Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 9 Apr 2002 02:31:58 +0000 Subject: [PATCH] Update refcursor documentation with examples of how to return pl/pgsql refcursors. --- doc/src/sgml/plsql.sgml | 113 +++++++++++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 25 deletions(-) diff --git a/doc/src/sgml/plsql.sgml b/doc/src/sgml/plsql.sgml index 8e87b41d9b..72298da8e3 100644 --- a/doc/src/sgml/plsql.sgml +++ b/doc/src/sgml/plsql.sgml @@ -1,5 +1,5 @@ @@ -762,7 +762,7 @@ CREATE FUNCTION logfunc2 (TEXT) RETURNS TIMESTAMP AS ' If the expression's result data type doesn't match the variable's data type, or the variable has a specific size/precision - (as for char(20)), the result value will be implicitly + (like char(20)), the result value will be implicitly converted by the PL/pgSQL interpreter using the result type's output-function and the variable type's input-function. Note that this could potentially @@ -880,7 +880,7 @@ PERFORM query; This executes a SELECT query and discards the result. PL/pgSQL variables are substituted - into the query as usual. + in the query as usual. @@ -927,7 +927,7 @@ EXECUTE query-string; Note in particular that no substitution of PL/pgSQL variables is done on the query string. The values of variables must - be inserted into the query string as it is constructed. + be inserted in the query string as it is constructed. @@ -1441,16 +1441,16 @@ END LOOP; Cursors - Rather than executing a whole query at once, it is possible to - set up a cursor that encapsulates the query, and - then read the query result a few rows at a time. One reason - for doing this is to avoid memory overrun when the result contains - a large number of rows. (However, PL/pgSQL users - don't normally need to worry about that, since FOR loops automatically - use a cursor internally to avoid memory problems.) A more interesting - possibility is that a function can return a reference to a cursor - that it has set up, allowing the caller to read the rows. This - provides one way of returning a row set from a function. + Rather than executing a whole query at once, it is possible to set + up a cursor that encapsulates the query, and then read + the query result a few rows at a time. One reason for doing this is + to avoid memory overrun when the result contains a large number of + rows. (However, PL/pgSQL users don't normally need + to worry about that, since FOR loops automatically use a cursor + internally to avoid memory problems.) A more interesting usage is to + return a reference to a cursor that it has created, allowing the + caller to read the rows. This provides one way of returning multiple + rows and columns from a function. @@ -1498,11 +1498,10 @@ DECLARE Before a cursor can be used to retrieve rows, it must be - opened. (This is the equivalent action to - the SQL command DECLARE CURSOR.) - PL/pgSQL has four forms of the OPEN statement, - two of which are for use with unbound cursor variables - and the other two for use with bound cursor variables. + opened. (This is the equivalent action to the SQL + command DECLARE CURSOR.) PL/pgSQL has + four forms of the OPEN statement, two of which use unbound cursor + variables and the other two use bound cursor variables. @@ -1518,7 +1517,7 @@ OPEN unbound-cursor FOR SELECT ...; have been declared as an unbound cursor (that is, as a simple refcursor variable). The SELECT query is treated in the same way as other SELECTs in PL/pgSQL: - PL/pgSQL variable names are substituted for, + PL/pgSQL variable names are substituted, and the query plan is cached for possible re-use. @@ -1539,8 +1538,8 @@ OPEN unbound-cursor FOR EXECUTE -- 2.40.0