repeat until
SQL/PL
Repeat execution of a list of statements until a condition becomes true
Syntax
repeat_stmt: [ label_name:] REPEAT statement_list UNTIL conditional_expr END REPEAT [ label_name]
Description
The REPEAT statement will repeatedly execute statement_list until the conditional_expr evaluates to true or until a LEAVE (or RETURN in a function) statement is executed. The conditional_expr is evaluated at the end of the loop.
If an ENDREPEAT specifies label_name then an identical opening label_name: must be specified as well.
Example
create procedure cflow(i1 int, i2 int)begin declare ii, ij int; if i1 < i2 then set (ii, ij) = (i1, i1); w_loop: while ii <= i2 do set ij = ij * ii; select i1, i2, ii, ij; set ii = ii + 1; if ii > 100 then leave w_loop; end if; end while; else set (ii, ij) = (i2, i1); r_loop: repeat set ij = ij + ii; select i1, i2, ii, ij; set ii = ii + 1; if ii > 100 then leave r_loop; end if; until ii > i1 end repeat; end if;end;
See Also