Skip to content

EXIT

DECLARE
x NUMBER := 0;
BEGIN
WHILE x < 10 LOOP
x := x + 1;
IF x = 5 THEN
EXIT;
END IF;
DBMS_OUTPUT.PUT_LINE('x = ' || x);
END LOOP;
END;
/
x = 1
x = 2
x = 3
x = 4

The EXIT statement terminates the LOOP when x equals 5. So, it prints the values of x from 1 to 4. When x becomes 5, it stops execution and exits the loop. Therefore, the output shows values only from 1 to 4.