pl-sql
  1. pl-sql-continue

Continue Statement in PL/SQL Control Statements

In PL/SQL, the continue statement is a control statement that is used to skip one iteration of a loop. It is typically used in combination with conditional statements to selectively skip over certain iterations of a loop.

Syntax

The syntax for the continue statement in PL/SQL is as follows:

CONTINUE;

Example

Here's an example of using the continue statement in PL/SQL:

DECLARE
  counter NUMBER := 0;
BEGIN
  LOOP
    counter := counter + 1;
    
    IF counter = 3 THEN
      CONTINUE;
    END IF;
    
    DBMS_OUTPUT.PUT_LINE('Counter: ' || counter);
    
    EXIT WHEN counter = 5;
  END LOOP;
END;

In this example, a loop is defined that iterates from 1 to 5. The if statement inside the loop checks if the counter is equal to 3 and skips the current iteration using the continue statement if that condition is true.

Output

Counter: 1
Counter: 2
Counter: 4
Counter: 5

Explanation

In the above example, the loop iterates from 1 to 5. During the third iteration, the counter variable has a value of 3 and the if statement is true. The continue statement causes the loop to skip to the next iteration, which is the fourth iteration. The output shows that the value 3 is not printed to the console.

Use

The continue statement is used in PL/SQL to selectively skip over certain iterations of a loop. It is typically used in combination with conditional statements to skip over iterations where a certain condition is true.

Important Points

  • The continue statement is used in PL/SQL to skip one iteration of a loop.
  • It is typically used in combination with conditional statements to selectively skip over certain iterations.
  • The continue statement causes the loop to immediately start a new iteration.

Summary

In summary, the continue statement in PL/SQL is a control statement that is used to skip over one iteration of a loop. It is typically used in combination with conditional statements to selectively skip certain iterations. The continue statement causes the loop to immediately start a new iteration.

Published on: