sequence of statements as long as the evaluation of
the condition expression is true.
</para>
<para>
<synopsis>
<optional><<label>></optional>
WHILE <replaceable>expression</replaceable> LOOP
<replaceable>statements</replaceable>
END LOOP;
</synopsis>
A conditional loop that is executed as long as the evaluation
of <replaceable>expression</replaceable> is true.
<synopsis>
</synopsis>
<para>
For example:
</para>
<programlisting>
WHILE amount_owed > 0 AND gift_certificate_balance > 0 LOOP
-- some computations here
END LOOP;
WHILE NOT boolean_expression LOOP
-- some computations here
END LOOP;
</programlisting>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
FOR
</term>
<listitem>
<para>
<synopsis>
<optional><<label>></optional>
FOR <replaceable>name</replaceable> IN <optional> REVERSE </optional> <replaceable>expression</replaceable> .. <replaceable>expression</replaceable> LOOP
<replaceable>statements</replaceable>
END LOOP;
</synopsis>
</synopsis>
A loop that iterates over a range of integer values. The variable
<replaceable>name</replaceable> is automatically created as type
integer and exists only inside the loop. The two expressions giving
the lower and upper bound of the range are evaluated only when entering
the loop. The iteration step is always 1.
<synopsis>
</para>
<para>
Some examples of FOR loops (see <xref linkend="plpgsql-description-records"></xref> for
iterating over records in FOR loops):
<programlisting>
FOR i IN 1..10 LOOP
-- some expressions here
RAISE NOTICE 'iis%',i;
END LOOP;
FOR i IN REVERSE 1..10 LOOP
-- some expressions here
END LOOP;
</programlisting>
</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
</sect2>
<!-- **** PL/pgSQL records **** -->
<sect2 id="plpgsql-description-records">
<title>Working with RECORDs</title>
<para>
Records are similar to rowtypes, but they have no predefined structure.
They are used in selections and FOR loops to hold one actual