Kayshav.com
About Developer Oracle 11g Technology Information Sitemap

Oracle 11g - Continue
-- The CONTINUE option can used based on the application requirements. In
-- this example, if value is less than reference value, the loop continues 
-- forward without incrementing the counter.

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

DECLARE
 i_val  SIMPLE_INTEGER := 0;
 i_idx  SIMPLE_INTEGER := 0;
 i_ref  SIMPLE_INTEGER := DBMS_RANDOM.value(0,5);

BEGIN
 DBMS_OUTPUT.PUT_LINE(' Ref Value -> '||i_ref);
 
 For i_idx IN 0..5 LOOP

  IF i_idx < i_ref THEN
    DBMS_OUTPUT.PUT_LINE(' i_idx ['||i_idx||'] Value -> '||i_val);
    CONTINUE;
  ELSE
    i_val := i_val+1;
  END IF;

  DBMS_OUTPUT.PUT_LINE(' i_idx ['||i_idx||'] Value -> '||i_val);
 END LOOP;
END;
/

Oracle 11g Continue [2] output

-- In this example shown below, if index value is less than reference value,
-- the test value is incremented, else loop continues forward.

DECLARE
 i_val  SIMPLE_INTEGER := 0;
 i_idx  SIMPLE_INTEGER := 0;
 i_ref  SIMPLE_INTEGER := DBMS_RANDOM.value(0,5);

BEGIN
 DBMS_OUTPUT.PUT_LINE(' Ref Value -> '||i_ref);
 
 For i_idx IN 0..5 LOOP

  IF i_idx < i_ref THEN
    i_val := i_val+1;
    DBMS_OUTPUT.PUT_LINE(' i_idx ['||i_idx||'] Value -> '||i_val);
  ELSE
    DBMS_OUTPUT.PUT_LINE(' i_idx ['||i_idx||'] Value -> '||i_val);
    CONTINUE;
  END IF;

 END LOOP;
END;
/

Oracle 11g Continue [3] output

Continue analysis

Oracle 11gXEr2 - Index

Oracle registered trademark of Oracle Corporation.

Last Revised On: October 19th, 2014

  17629