• Post author:
  • Post category:All / PLSQL
  • Reading time:2 mins read
The CONTINUE statement in loops exits the current iteration of a loop unconditionally and transfers control to the next iteration of either the current loop or an enclosing labeled loop.
In below example, the CONTINUE statement inside the basic LOOP statement transfers control unconditionally to the next iteration of the current loop.

   x   NUMBER := 0;
   LOOP                      -- After CONTINUE statement, control resumes here
      DBMS_OUTPUT.PUT_LINE ('Inside loop: x = ' || TO_CHAR (x));
      x := x + 1;


      IF x < 3  -- instead this if end if condition for continue you can use also CONTINUE When x < 3;
      END IF;

         'Inside loop, after CONTINUE: x = ' || TO_CHAR (x));
      EXIT WHEN x = 5;


   DBMS_OUTPUT.PUT_LINE (' After loop: x = ' || TO_CHAR (x));
The output of the above block should come something like this:

Inside loop: x = 0
Inside loop: x = 1
Inside loop: x = 2
Inside loop, after CONTINUE: x = 3
Inside loop: x = 3
Inside loop, after CONTINUE: x = 4
Inside loop: x = 4
Inside loop, after CONTINUE: x = 5
After loop: x = 5

Related:  Blogger Introduced New Themes in 2017

Vinish Kapoor

An Oracle Apex Consultant, Oracle ACE, and founder of foxinfotech.in and orclqa.com a question and answer forum for developers.