GOTO
From SQL PL Guide for DB2
GOTO statement
The GOTO statement can be used to jump to a specific label in a stored procedure. It's a straightforward and basic flow of control statement.
It's not a good programming style to use the GOTO statement and it should be avoided if possible. The code will be unreadable if you're using the statement to often.
Syntax:
GOTO <label>;
Example:
CREATE PROCEDURE num_emp_hired_in_xxxx (IN year_hired SMALLINT, OUT num_of_emp INTEGER)
LANGUAGE SQL
BEGIN
IF (year_hired < 1949) OR (year_hired > year(CURRENT DATE))
THEN
SET num_of_emp = -1;
GOTO exit_sp;
END IF;
SELECT count(*) INTO num_of_emp FROM employee where year(hiredate) = year_hired;
exit_sp:
BEGIN END;
END!