MySQL Leave

MySQL Leave

Leave statement is used to exit the flow control construct that has the given label.
MySQL Leave syntax and example.

Leave example

CREATE PROCEDURE leave_proc(a INT)
BEGIN
  p_label: LOOP
    SET a = a + 1;
    IF a < 3 THEN
      ITERATE p_label;
    END IF;
    LEAVE p_label;
  END LOOP p_label;
  SET @b = a;
END;

Output

PROCEDURE LEAVE_PROC compiled