aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2006-06-12 16:45:30 +0000
committerBruce Momjian <bruce@momjian.us>2006-06-12 16:45:30 +0000
commit07c25723dae380a3163981cff1028e7c289e7eb4 (patch)
tree61e85f5897da9dae13e22893724cdaa95ae589b3 /doc/src
parente6a7b01930dba76570f5a6c7c34a05caeb0ccebb (diff)
downloadpostgresql-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.sgml15
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> &lt;&lt;<replaceable>label</replaceable>&gt;&gt; </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>