PL/SQL Continue Statement
PL/SQL CONTINUE Statement are control your iteration loop, PL/SQL CONTINUE Statement to skip the current iteration with in loop.
The continue statement is used to exit the loop from the reminder if its body either conditionally or unconditionally and forces the next iteration of the loop to take place, skipping any codes in between.
Syntax:
continue;
Example of PL/SQL continue statement
Example:
DECLARE
no NUMBER := 0;
BEGIN
FOR no IN 1 .. 5 LOOP
IF i = 4 THEN
CONTINUE;
END IF;
DBMS_OUTPUT.PUT_LINE('Iteration : ' || no);
END LOOP;
END;
/
Result:
Iteration # 1
Iteration # 2
Iteration # 3
Iteration # 5
PL/SQL procedure successfully completed.
PL/SQL GOTO Statement
PL/SQL GOTO statement allows you to jump to a specific executable statement in the same execution section of a PL/SQL block.
Syntax:
GOTO label_name;
Where label_name is a label that defines the target statement. In a program, you define a label as follows:
<<label_name>>
The label name is enclosed in double angle brackets ( <<>>).
Example:
BEGINFOR i IN 1..5 LOOP
dbms_output.put_line(i);
IF i=4 THEN
GOTO label1;
END IF; END LOOP; <<label1>>
DBMS_OUTPUT.PUT_LINE('Row Filled');
END;
/
Result:
1
2
3
4
Row Filled
PL/SQL procedure successfully completed.