Pre-General Availability Draft: 2018-02-21
[begin_label:] BEGIN [statement_list] END [end_label] [begin_label:] LOOP statement_list END LOOP [end_label] [begin_label:] REPEAT statement_list UNTIL search_condition END REPEAT [end_label] [begin_label:] WHILE search_condition DO statement_list END WHILE [end_label]
begin_labelmust be followed by a colon.
begin_labelcan be given without
end_labelis present, it must be the same as
end_labelcannot be given without
Labels at the same nesting level must be distinct.
Labels can be up to 16 characters long.
CREATE PROCEDURE doiterate(p1 INT) BEGIN label1: LOOP SET p1 = p1 + 1; IF p1 < 10 THEN ITERATE label1; END IF; LEAVE label1; END LOOP label1; END;
The scope of a block label does not include the code for handlers declared within the block. For details, see Section 22.214.171.124, “DECLARE ... HANDLER Syntax”.