New PL/SQL Feature in Oracle 11g: CONTINUE 20188367001

New PL/SQL Feature in Oracle 11g: CONTINUE

A minor new PL/SQL feature in Oracle 11g is the new statement ‘continue’.  With the continue statement you can skip to the next iteration in a loop. A small example:

begin
  for i in 1..3
  loop
    dbms_output.put_line('i='||to_char(i));
    if ( i = 2 )
    then
      continue;
    end if;
    dbms_output.put_line('Only if i is not equal to 2');
  end loop;
end;

SQL> i=1
Only if i is not equal to 2
i=2
i=3
Only if i is not equal to 2

PL/SQL-procedure is geslaagd.

Or you can use
the ‘continue when’ statement to determine when to go to the next iteration in the loop.

begin
  for i in 1..3
  loop
    dbms_output.put_line('i='||to_char(i));
    continue when ( i = 2 );
    dbms_output.put_line('Only if i is not equal to 2');
  end loop;
end;

SQL> i=1
Only if i is not equal to 2
i=2
i=3
Only if i is not equal to 2

4 Comments

  1. Jeffrey Han July 22, 2007
  2. Gareth July 13, 2007
  3. Patrick Wolf July 12, 2007
  4. Lucas Jellema July 12, 2007