Search code examples
plsqloracle10gcontinue

How to Mimic a Continue Statement in a Cursor-For-Loop in Oracle 10G PL/SQL?


In Oracle 10g, there is no continue statement. Typically it is mimicked in an explicit cursor like such:

OPEN c_cur ;
<<cont>>
LOOP
    ...
    IF condition = 10 THEN
        GOTO cont ;
    END IF;
END LOOP;
CLOSE c_cur ;

Given that the LOOP keyword immediately follows the cursor in the cursor-for-loop syntax, how can a continue statement be mimicked?

FOR rec IN c_cur LOOP
    ...
END LOOP ;

Solution

  • FOR rec IN c_cur LOOP
        ...
        IF condition = 10 THEN
            GOTO cont ;
        END IF ;
    
    <<CONT>>
    NULL; -- END cannot be immediately preceeded by a <<marker>>
    
    END LOOP ;