REPEAT statement
The REPEAT statement executes a statement or group of statements until a search condition is true.
Syntax
Description
- label
- Specifies the label for the REPEAT statement. If the ending label
is specified, the beginning label must be specified, and the two must
match.
A label name cannot be the same as the name of the SQL procedure in which the label is used.
- SQL-procedure-statement
- Specifies the statements to be executed. The statement must be one of the statements listed under SQL-procedure-statement (external).
- search-condition
- Specifies a condition that is evaluated after each execution of the REPEAT statement. If the condition is true, the REPEAT loop will exit. If the condition is unknown or false, the REPEAT loop continues.
Examples
Use a REPEAT statement to fetch rows from a table.
fetch_loop:
REPEAT
FETCH c1 INTO
v_firstnme, v_midinit, v_lastname;
UNTIL
SQLCODE <> 0
END REPEAT fetch_loop 