PL/SQL Exception

PL/SQL Exception

PL/SQL Interview Questions

PL/SQL Interview Questions and Answers


PL/SQL Exit Loop Statement

The PL/SQL LOOP allows you to iterative sequence of statements repeatedly for a specified number of times. The EXIT WHEN is used to terminate the loop iteration. Here remember that the EXIT and EXIT WHEN statement can be used interchangeably.

PL/SQL Exit Loop Statement Syntax

To terminate the loop iteration, use the following syntax:

Syntax

PL/SQL Exit Loop Statement example with EXIT WHEN Statement

The following PL/SQL uses to terminate LOOP using EXIT WHEN statement:

Example

Let's understand how it works:

  • First, we initialize the counter to 100.
  • Second, in each iteration, we increasing counter with 1.
  • Third, we display the result of the counter.
  • Fourth, The loop is terminated when the counter reaches to 50.