PL/SQL CONTINUE Statement
PL/SQL CONTINUE Statement (Sequential Control Statements) are control your iteration loop, PL/SQL CONTINUE Statement to skip the current iteration with in loop.
- CONTINUE Statement : to skip the current iteration with in loop.
- CONTINUE WHEN Statement : to skip the current iteration with in loop when WHEN clauses condition true.
CONTINUE Statement
CONTINUE Statement unconditionally skip the current loop iteration and next iteration iterate as normal, only skip matched condition.
Syntax
IF condition THEN
CONTINUE;
END IF;
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.
Iteration # 2
Iteration # 3
Iteration # 5
PL/SQL procedure successfully completed.
CONTINUE WHEN Statement
CONTINUE WHEN Statement unconditionally skip the current loop iteration when WHEN clauses condition true,
Syntax
CONTINUE WHEN condition;
statement(s);
Example
DECLARE
no NUMBER := 0;
BEGIN
FOR no IN 1 .. 5 LOOP
DBMS_OUTPUT.PUT_LINE('Iteration : ' || no);
CONTINUE WHEN no = 4
DBMS_OUTPUT.PUT_LINE('CONTINUE WHEN EXECUTE Iteration : ' || no);
END LOOP;
END;
/
Result
Iteration # 1
Iteration # 2
Iteration # 3
CONTINUE WHEN EXECUTE Iteration : 4
Iteration # 5
PL/SQL procedure successfully completed.
Iteration # 2
Iteration # 3
CONTINUE WHEN EXECUTE Iteration : 4
Iteration # 5
PL/SQL procedure successfully completed.