PLSQL - Nested Loops


Syntax:

DECLARE

BEGIN

LOOP

EXIT WHEN TRUE

LOOP

EXIT WHEN TRUE

END LOOP

END LOOP

END

Example for Nested Loop:

declare

v_dept number;

v_emp number;

begin

v_dept := 1;

loop -- First 4 departments Loop

exit when v_dept > 4;

v_emp := 1;

loop -- First 3 Employees Loop

exit when v_emp >= 3;

v_emp := v_emp + 1;

end loop;

v_dept := v_dept + 1;

end loop;

end;

Complete Tutorial

*/

No comments:

Post a Comment