EXIT statement (PL/SQL)
The EXIT statement terminates execution of a loop within a PL/SQL code block.
Invocation
This statement can be embedded within a FOR, LOOP, or WHILE statement in a PL/SQL procedure, function, or anonymous block.
Authorization
No privileges are required to invoke the EXIT statement. However, the authorization ID of the statement must hold the necessary privileges to invoke the SQL statements that are embedded within the FOR, LOOP, or WHILE statement.
Syntax
Example
The following example shows a basic
LOOP statement with an EXIT statement within an anonymous block:
DECLARE
sum PLS_INTEGER := 0;
BEGIN
LOOP
sum := sum + 1;
IF sum > 10 THEN
EXIT;
END IF;
END LOOP;
END