Oracle Plsql Exit Statement

Oracle / PLSQL: Exit Statement

This Oracle tutorial explains how to use the EXIT statement in Oracle with syntax and examples.

Description

In Oracle, the EXIT statement is most commonly used to terminate LOOP statements.

Syntax

The syntax for the EXIT statement in Oracle/PLSQL is:

EXIT [WHEN <strong>boolean_condition</strong>];

Parameters or Arguments

boolean_condition

Optional. It is the condition to terminate the LOOP.

Example

Let's look at an EXIT Example in Oracle/PLSQL:

LOOP
   monthly_value := daily_value * 31;
   EXIT WHEN monthly_value > 4000;
END LOOP;

In this example, the LOOP would terminate when the monthly_value exceeded 4000.