From 07c25723dae380a3163981cff1028e7c289e7eb4 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 12 Jun 2006 16:45:30 +0000 Subject: Add BY clause to PL/PgSQL FOR loop, to control the iteration increment. Jaime Casanova --- doc/src/sgml/plpgsql.sgml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index f0cbbf2896c..60c7593362b 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 @@ -1975,7 +1975,7 @@ END LOOP; <<label>> -FOR name IN REVERSE expression .. expression LOOP +FOR name IN REVERSE expression .. expression BY expression LOOP statements END LOOP label ; @@ -1988,8 +1988,10 @@ END LOOP label ; definition of the variable name is ignored within the loop). The two expressions giving the lower and upper bound of the range are evaluated once when entering - the loop. The iteration step is normally 1, but is -1 when REVERSE is - specified. + the loop. If the BY clause isn't specified the iteration + step is 1 otherwise it's the value specified in the BY + clause. If REVERSE is specified then the step value is + considered negative. @@ -2003,6 +2005,11 @@ END LOOP; FOR i IN REVERSE 10..1 LOOP -- some computations here END LOOP; + +FOR i IN REVERSE 10..1 BY 2 LOOP + -- some computations here + RAISE NOTICE 'i is %', i; +END LOOP; -- cgit v1.2.3