From 4adead1d224278ff3064636063a818eba17cb211 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 14 Dec 2011 15:55:37 +0200 Subject: Add support for passing cursor parameters in named notation in PL/pgSQL. Yeb Havinga, reviewed by Kevin Grittner, with small changes by me. --- doc/src/sgml/plpgsql.sgml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index f33cef55ed0..5a1e33fb4be 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -2823,11 +2823,11 @@ OPEN curs1 FOR EXECUTE 'SELECT * FROM ' || quote_ident(tabname) - + Opening a Bound Cursor -OPEN bound_cursorvar ( argument_values ) ; +OPEN bound_cursorvar ( argument_name := argument_value , ... ) ; @@ -2846,11 +2846,22 @@ OPEN bound_cursorvar ( argume behavior was already determined. + + Argument values can be passed using either positional + or named notation. In positional + notation, all arguments are specified in order. In named notation, + each argument's name is specified using := to + separate it from the argument expression. Similar to calling + functions, described in , it + is also allowed to mix positional and named notation. + + Examples (these use the cursor declaration examples above): OPEN curs2; OPEN curs3(42); +OPEN curs3(key := 42); @@ -3169,7 +3180,7 @@ COMMIT; <<label>> -FOR recordvar IN bound_cursorvar ( argument_values ) LOOP +FOR recordvar IN bound_cursorvar ( argument_name := argument_value , ... ) LOOP statements END LOOP label ; @@ -3180,7 +3191,11 @@ END LOOP label ; the cursor again when the loop exits. A list of actual argument value expressions must appear if and only if the cursor was declared to take arguments. These values will be substituted in the query, in just - the same way as during an OPEN. + the same way as during an OPEN (see ). + + + The variable recordvar is automatically defined as type record and exists only inside the loop (any existing definition of the variable name is ignored within the loop). -- cgit v1.2.3