LOOP

Allows one or more procedural-sql-statements to be iteratively executed.

loop.png

 

Usage

Procedural.

Description

The LOOP statement can be used to iteratively execute a sequence of one or more procedural SQL statement.

For information on procedural-sql-statements, see Procedural SQL Statements.

Restrictions

If label appears at the beginning and at the end of the LOOP statement, the same value must be specified in both places.

Specifying label is optional, however, if label appears at the end of the LOOP statement, it must also appear at the beginning.

A label is required at the beginning if the LEAVE statement is to be used to terminate the LOOP statement.

Notes

The LOOP statement itself does not include a mechanism for terminating the iteration.

The LOOP statement can be terminated by executing the LEAVE statement. The LOOP statement will also terminate if an exception condition is raised, in accordance with the normal exception handling process.

The LOOP statement does not establish any form of local scope, as the compound statement does, the label is only specified to allow the LEAVE statement to be used to terminate the iteration.

Example

L1:

LOOP

 ...

 

   LEAVE L1;

 ...

END LOOP L1;

 

For more information, see the Mimer SQL Programmer's Manual, Iteration

Standard Compliance

Standard

Compliance

Comments

SQL-2016

Features outside core

Feature P002, “Computational completeness”.