602SQL Documentation Index  

REPEAT Statement

statement_REPEAT ::= [ label : ] REPEAT statement  UNTIL condition END REPEAT [ label ];

The statements (or block statements) specified in the REPEAT statement are executed repeatedly and the condition is evaluated when this statement is called. Statement execution is terminated if the condition equals TRUE, the LEAVE statement is executed, or an error occurs.

If an ending label is set, the same starting label must be set. No statement inside the REPEAT statement may be designated with the same label.

Example:

Insert 10 records into a table and enumerate them ascending.

PROCEDURE Rep ();
BEGIN
  DECLARE i INT DEFAULT 1; 
  REPEAT
    INSERT INTO Tab3 (number) VALUES (i); 
    SET i = i + 1; 
  UNTIL  i > 10  END REPEAT; 
END;