Nested Loops

0
Nested Loops:
 

  • It is a situation where one loop is embedded into the other.
  • The outer loop and the inner loop get associated with one another and execute simultaneously.
  • The overall loop terminates is dictated  by the outer loop’s “EXIT WHEN” condition or “EXIT” condition.
  • In nested loop’s the outer loops condition evaluated as TRUE, always makes the inner loop to resume its process ad the inner loop’s termination actually makes the outer loop to update its process.

SQL>DECLARE
    v_num NUMBER:=1;
    BEGIN
    LOOP
    EXIT WHEN v_num>10;
       LOOP
    EXIT WHEN v_num>5;
    display(‘Inner loop:’||v_num);
    v_num:=v_num+1;
    END LOOP;
     display(‘Outer loop:’||v_num);
    v_num:=v_num+1;
    END LOOP;
    END;


 Click here to go to Back page

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts