REPEAT
The REPEAT statement is used in SQL Script to repeat specific statements under specific conditions.
Syntax
[<label>:] REPEAT
<statements>
UNTIL <conditionalExpression>
END REPEAT [<label>]
Remarks
• The label is an optional identifier to name the block. The REPEAT statement is for use with the LEAVE and ITERATE statements. See
LEAVE and
ITERATE.
• If a beginning label is present, the end label is not required. If no beginning label is present, it is illegal to have an end label. If both the beginning and end labels are present, both must have the same identifier.
• The <statements> area can have zero or more statements.
Example
--Returns the root of ID
PROCEDURE
BEGIN
DECLARE parent_ID INTEGER DEFAULT ID;
REPEAT
SET result = parent_ID;
CALL /shared/parent_of (result, parent_ID);
UNTIL parent_ID IS NULL
END REPEAT;
END