Intro
In this article, I will raise awareness on a PLSQL feature that is too often ignored.
The CONTINUE clause in PL/SQL is a powerful control structure that allows you to skip the remaining statements in the current iteration of a loop and move directly to the next iteration.
It helps make code cleaner and avoids deeply nested IF conditions when certain cases should be ignored.
As far as I remember, this feature was introduced in Oracle 11g and it can be commonly used in LOOP, WHILE, and FOR loops.
What is the CONTINUE Clause?
In Oracle Database’s procedural language PL/SQL, the CONTINUE statement:
- Immediately proceeds to the next iteration
- Skips the rest of the loop body
- Can be used conditionally (CONTINUE WHEN); example to follow
Basic Syntax
Example 1: Simple CONTINUE in a LOOP
CONTINUE;
IN is example we would want to exclude from processing the rows with value 3:
set serveroutput onBEGIN FOR i IN 1..12 LOOP IF i = 3 THEN CONTINUE; END IF; DBMS_OUTPUT.PUT_LINE('Value: ' || i); END LOOP;END;
returns as below and when i = 3, the CONTINUE skips printing and moves to the next iteration
Value: 1Value: 2Value: 4Value: 5Value: 6Value: 7Value: 8Value: 9Value: 10Value: 11Value: 12PL/SQL procedure successfully completed

Example 2: Using CONTINUE WHEN
This is a cleaner and more concise way.Code snippet example:
BEGIN FOR i IN 1..8 LOOP CONTINUE when i >6; DBMS_OUTPUT.PUT_LINE('Value: ' || i); END LOOP;END;
Only the values smaller or equal to six should be printed:
Value: 1Value: 2Value: 3Value: 4Value: 5Value: 6PL/SQL procedure successfully completed.

Example 3: Skipping Even Numbers
The example will skip the even numbers from processing and list all odd numbers up to 30:
BEGIN FOR i IN 1..30 LOOP CONTINUE WHEN MOD(i, 2) = 0; DBMS_OUTPUT.PUT_LINE('Odd number==> ' || i); END LOOP;END;
Odd number==> 1Odd number==> 3Odd number==> 5Odd number==> 7Odd number==> 9Odd number==> 11Odd number==> 13Odd number==> 15Odd number==> 17Odd number==> 19Odd number==> 21Odd number==> 23Odd number==> 25Odd number==> 27Odd number==> 29PL/SQL procedure successfully completed.

Example 4: CONTINUE in WHILE Loop
Will stop processing when the values goes above 8:
DECLARE i NUMBER := 0;BEGIN WHILE i < 15 LOOP i := i + 1; CONTINUE WHEN i > 8; DBMS_OUTPUT.PUT_LINE('Value: ' || i); END LOOP;END;Output:Value: 1Value: 2Value: 3Value: 4Value: 5Value: 6Value: 7Value: 8PL/SQL procedure successfully completed.

Example 5: Nested Loops with CONTINUE
As expected, CONTINUE statement will ‘continue’ to work within the inner loop :)
For this case, the rows where j has value 2 will be skipped from displaying (or processing):
BEGIN FOR i IN 1..3 LOOP FOR j IN 1..3 LOOP CONTINUE WHEN j = 2; DBMS_OUTPUT.PUT_LINE('i=' || i || ', j=' || j); END LOOP; END LOOP;END;
generates:
i=1, j=1i=1, j=3i=2, j=1i=2, j=3i=3, j=1i=3, j=3PL/SQL procedure successfully completed.

Best Practices
Disclaimer: like with the other best practices I publish, please note that those are derived from real production examples. in case you need help, please reach out or otherwise, use at own risk!
| Prefer CONTINUE WHEN for readability |
| Avoid overusing nested IF blocks—use CONTINUE instead |
| Use labels carefully to avoid confusing logic in nested loops |
| Combine with conditions for cleaner filtering logic |
Summary
The CONTINUE clause in PL/SQL is a simple yet powerful feature that improves:
- Code clarity
- Maintainability
- Performance (by skipping unnecessary logic)
It’s especially useful in loops where certain conditions should bypass processing without terminating the loop entirely
Also, it is great for:
- Data validation
- ETL jobs
- Bulk processing
- Error handling
Considering how important those use cases are for the modern Entreprise, I would like to see this feature used in more such cases, if not all!
