PL/SQL Loop – Exit

LOOP … EXIT Loop syntax

LOOP
	--pl/sql statements
	IF condition THEN
		EXIT;
	END IF;
	--pl/sql statements
END LOOP;

LOOP … EXIT Loop example

DECLARE
  i NUMBER:=0;
BEGIN
DBMS_OUTPUT.PUT_LINE('Start');
	LOOP
		i := i + 1;
		IF i > 3 THEN
			EXIT;
		END IF;
		DBMS_OUTPUT.PUT_LINE(' i: ' || i);
	END LOOP;
DBMS_OUTPUT.PUT_LINE('End');
END;

Output

Start
 i: 1
 i: 2
 i: 3
End