Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'CONTINUE' keyword in Oracle 10g PL/SQL

I'm migrating a TSQL stored procedure to PL/SQL and have encountered a problem - the lack of a CONTINUE keyword in Oracle 10g.

I've read that Oracle 11g has this as a new feature, but upgrading is not an option unfortunately.

Is there any alternative to CONTINUE in 10g? I don't believe it's practical to restructure the logic of the SP as a work-around, because I have an outer loop, an IF, then a nested IF, then the CONTINUE at the end of a statement block within that IF.

Any help would be greatly appreciated, cheers.

like image 364
Chris McAtackney Avatar asked Oct 07 '08 09:10

Chris McAtackney


People also ask

In which Oracle does the PL SQL continue statement is supported?

The CONTINUE statement has finally been added to PL/SQL in Oracle 11g, allowing you to jump out of the current iteration of a loop.

What is continue in Oracle?

The CONTINUE statement exits the current iteration of a loop, either conditionally or unconditionally, and transfers control to the next iteration of either the current loop or an enclosing labeled loop.

Which form of continue will exit any loop in PL SQL?

Oracle Database 11g offers a new feature for loops: the CONTINUE statement. Use this statement to exit the current iteration of a loop, and immediately continue on to the next iteration of that loop. This statement comes in two forms, just like EXIT: the unconditional CONTINUE and the conditional CONTINUE WHEN.

What is continue in PL SQL?

PL/SQL CONTINUE statement The CONTINUE statement allows you to exit the current loop iteration and immediately continue on to the next iteration of that loop. The CONTINUE can be used in all loop constructs including LOOP , FOR LOOP and WHILE LOOP .


1 Answers

You can simulate a continue using goto and labels.

DECLARE    done  BOOLEAN; BEGIN    FOR i IN 1..50 LOOP       IF done THEN          GOTO end_loop;       END IF;    <<end_loop>>  -- not allowed unless an executable statement follows    NULL; -- add NULL statement to avoid error    END LOOP;  -- raises an error without the previous NULL END; 
like image 111
jop Avatar answered Oct 02 '22 14:10

jop