PL/SQL Iterative Control

The LOOP statements allow you to execute one or more sequence of statements multiple times. There are three forms of LOOP statements: LOOP, WHILE-LOOP, FOR-LOOP.

LOOP

LOOP
   -- sequence of statements
END LOOP;

EXIT

LOOP
  v_count := 10;
  IF v_count = 10 THEN 
    EXIT;
  END IF;
END LOOP;

EXIT-WHEN

LOOP
  v_count := v_count + 10;
    EXIT WHEN v_count = 11;
END LOOP;

FOR-LOOP

FOR counter IN [REVERSE] lower_number..higher_number LOOP
   -- sequence of statements
END LOOP;

WHILE-LOOP

WHILE condition LOOP
   -- sequence of statements
END LOOP;

Examples