From f01b1965971ddd3345d3e44e00d0d735a49b75d1 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 16 Apr 2007 17:21:24 +0000 Subject: Support scrollable cursors (ie, 'direction' clause in FETCH) in plpgsql. Pavel Stehule, reworked a bit by Tom. --- doc/src/sgml/plpgsql.sgml | 66 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 17 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index e6f7309c650..abfc8b6ec64 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,4 +1,4 @@ - + <application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language @@ -2364,10 +2364,14 @@ SELECT merge_db(1, 'dennis'); Another way is to use the cursor declaration syntax, which in general is: -name CURSOR ( arguments ) FOR query; +name NO SCROLL CURSOR ( arguments ) FOR query; (FOR can be replaced by IS for Oracle compatibility.) + If SCROLL is specified, the cursor will be capable of + scrolling backward; if NO SCROLL is specified, backward + fetches will be rejected; if neither specification appears, it is + query-dependent whether backward fetches will be allowed. arguments, if specified, is a comma-separated list of pairs name datatype that define names to be @@ -2409,7 +2413,7 @@ DECLARE <command>OPEN FOR</command> <replaceable>query</replaceable> -OPEN unbound_cursor FOR query; +OPEN unbound_cursor NO SCROLL FOR query; @@ -2422,7 +2426,8 @@ OPEN unbound_cursor FOR queryPL/pgSQL: PL/pgSQL variable names are substituted, and the query plan is cached for - possible reuse. + possible reuse. The SCROLL and NO SCROLL + options have the same meanings as for a bound cursor. @@ -2437,7 +2442,7 @@ OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey; <command>OPEN FOR EXECUTE</command> -OPEN unbound_cursor FOR EXECUTE query_string; +OPEN unbound_cursor NO SCROLL FOR EXECUTE query_string; @@ -2447,8 +2452,10 @@ OPEN unbound_cursor FOR EXECUTE + + + Examples: FETCH curs1 INTO rowvar; FETCH curs2 INTO foo, bar, baz; +FETCH LAST FROM curs3 INTO x, y; +FETCH RELATIVE -2 FROM curs4 INTO x; -- cgit v1.2.3