Kayshav.com
About Developer Oracle 11g Technology Information Sitemap

Oracle 11g PL/SQL - Continue
-- The example below shows the Oracle 11g PL/SQL CONTINUE feature that 
-- can be used to loop forward when a CONTINUE statement condition 
-- evaluates to be true.  In the example below, the SQRT() function
-- is computed only when the continue statement condition is true.
-- The base index value (i_val) and post continue index value (i_idx)
-- are displayed only after continue statement condition evaluates to
-- false.  The i_idx gets incremented only after continue statement
-- evaluates to false.

-- Without the CONTINUE statement, both i_val and i_idx would have 
-- looped to reach the same values (based on i_max - computed by the
-- random value). 

SET TIMING ON;
SET PAGESIZE 60;
SET SERVEROUTPUT ON SIZE 1000000;

DECLARE
 i_val  SIMPLE_INTEGER := 0;
 i_sqrt  SIMPLE_FLOAT := 0;
 i_idx  SIMPLE_INTEGER := 0;
 i_max  SIMPLE_INTEGER := DBMS_RANDOM.value(0,5);

BEGIN
 DBMS_OUTPUT.PUT_LINE(' Max Value -> '||i_max);
 
 LOOP
  i_val := i_val+1;

  IF i_val < 3 THEN
    i_sqrt := SQRT(i_val);
    DBMS_OUTPUT.PUT_LINE(' SQRT('||i_val||') Value -> '||i_sqrt);
    CONTINUE;
  END IF;

  i_idx := i_idx + 1;
  DBMS_OUTPUT.PUT_LINE(' Base Value -> '||i_val||
     ' Post Continue -> '||i_idx);

  EXIT WHEN i_val > i_max;
 END LOOP;
END;
/

Oracle 11g Continue output

More Examples -> Continue

Oracle 11gXEr2 - Index

Oracle registered trademark of Oracle Corporation.

Last Revised On: October 19th, 2014

  17621