-- 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; / -- 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; /
17629