CONTINUE Statement
In PL/SQL (Procedural Language/Structured Query Language), the CONTINUE statement is used within loops to skip the remaining statements within the loop for the current iteration and move on to the next iteration. The CONTINUE statement is commonly used in combination with conditional statements to control the flow of execution in loops.
Syntax:
CONTINUE;
Example:
DECLARE
i NUMBER := 1;
BEGIN
LOOP
IF i = 3 THEN
-- Skip the rest of the loop for i = 3
i := i + 1;
CONTINUE;
END IF;
-- Process other statements inside the loop
DBMS_OUTPUT.PUT_LINE('Current Value of i: ' || i);
i := i + 1;
EXIT WHEN i > 5; -- Exit the loop when i exceeds 5
END LOOP;
END;
/
When the above code is executed in SQL prompt, it produces the following output.
Output:
Current Value of i: 1
Current Value of i: 2
Current Value of i: 4
Current Value of i: 5
PL/SQL CONTINUE Statement
PL/SQL is a block-structured language that enables developers to combine the power of SQL with procedural statements. All the statements of a block are passed to the Oracle engine all at once which increases processing speed and decreases the traffic.