diff options
author | Bruce Momjian <bruce@momjian.us> | 2006-06-12 16:45:30 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2006-06-12 16:45:30 +0000 |
commit | 07c25723dae380a3163981cff1028e7c289e7eb4 (patch) | |
tree | 61e85f5897da9dae13e22893724cdaa95ae589b3 /doc/src | |
parent | e6a7b01930dba76570f5a6c7c34a05caeb0ccebb (diff) | |
download | postgresql-07c25723dae380a3163981cff1028e7c289e7eb4.tar.gz postgresql-07c25723dae380a3163981cff1028e7c289e7eb4.zip |
Add BY clause to PL/PgSQL FOR loop, to control the iteration increment.
Jaime Casanova
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 15 |
1 files changed, 11 insertions, 4 deletions
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 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.94 2006/05/30 13:40:55 momjian Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.95 2006/06/12 16:45:30 momjian Exp $ --> <chapter id="plpgsql"> <title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title> @@ -1975,7 +1975,7 @@ END LOOP; <synopsis> <optional> <<<replaceable>label</replaceable>>> </optional> -FOR <replaceable>name</replaceable> IN <optional> REVERSE </optional> <replaceable>expression</replaceable> .. <replaceable>expression</replaceable> LOOP +FOR <replaceable>name</replaceable> IN <optional> REVERSE </optional> <replaceable>expression</replaceable> .. <replaceable>expression</replaceable> <optional> BY <replaceable>expression</replaceable> </optional> LOOP <replaceable>statements</replaceable> END LOOP <optional> <replaceable>label</replaceable> </optional>; </synopsis> @@ -1988,8 +1988,10 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>; 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 <literal>REVERSE</> is - specified. + the loop. If the <literal>BY</> clause isn't specified the iteration + step is 1 otherwise it's the value specified in the <literal>BY</> + clause. If <literal>REVERSE</> is specified then the step value is + considered negative. </para> <para> @@ -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; </programlisting> </para> |