Unconditional Control Statements
Two of the least-used control structures are the GOTO and
NULL unconditional statements. The GOTO statement forces the flow of processing
to branch to a label unconditionally. When executed, the GOTO statement
transfers control to the labeled statement or block.
Syntax:
GOTO label_name;
For example, the GOTO statement is used to transfer
processing control to the label new_employee:
SELECT COUNT(*), empno INTO
emp_count
FROM employee
FOR counter 1..emp_count LOOP
SELECT empno FROM salary;
IF empno > 10000 THEN
GOTO
new_employee;
ELSE
INSERT INTO
emp_audit VALUES (:user_name, empno);
END IF;
<< new_employee>>
INSERT INTO employee VALUES
(empno);
INSERT INTO emp_audit VALUES
(:user_name, empno);
END LOOP;
GOTO Statements cannot do the following:
1) Branch into an IF or LOOP statement or sub-block.
2) Branch out of a subprogram.
3) Branch out of an exception handler in the current block.