The EXIT statement is used to force a loop to terminate unconditionally. When an EXIT statement is encountered within a loop, the loop is completed and the control is passed to the next statement after the loop. Following is the syntax of the EXIT statement:
LOOP
.....
IF condition THEN
Statements for Processing ....
EXIT;
END IF;
END LOOP;
The EXIT-WHEN statement terminates a loop when the given condition is fulfilled. When the EXIT statement is encountered, first the condition is checked. If the condition is TRUE, then the loop is completed and the control is passed to the statement after the loop. Following is the syntax of the EXIT-WHEN statement:
LOOP
.....
IF condition THEN
Statements for Processing ....
EXIT WHEN condition....
END IF;
END LOOP;
LOOP
.....
IF condition THEN
Statements for Processing ....
EXIT;
END IF;
END LOOP;
The EXIT-WHEN statement terminates a loop when the given condition is fulfilled. When the EXIT statement is encountered, first the condition is checked. If the condition is TRUE, then the loop is completed and the control is passed to the statement after the loop. Following is the syntax of the EXIT-WHEN statement:
LOOP
.....
IF condition THEN
Statements for Processing ....
EXIT WHEN condition....
END IF;
END LOOP;