How to Work With EXIT Statement in PL/SQL

In this article I am going to explain how to work with EXIT statement in PL/SQL.
  • 2115

Introduction

PL/SQL is define as procedure language/structure query language.  PL/SQL is developed by oracle. PL/SQL supports many feature like variables, loops, conditions  and exceptions. It also support the concept of array. In present time PL/SQL is integrated component of oracle software. SQL provide limited support for advance programming and PL/SQL fill this gap.

Block is a basic unit of a PL/SQL application. This block is collection of PL/SQL statements grouped as logical unit. Using  PL/SQL blocks you can create five different type of program units.

  • Stored Function
  • Stored procedure
  • Anonymous Block
  • Trigger
  • Package

EXIT Statement in PL/SQL

A simple loop is an infinite loop because it doesn't have any condition to terminate. To terminate this simple loop we use EXIT statement. Exit statement is two type

  • EXIT (Without any condition)
  • EXIT [label-name]  WHEN condition

Example

DECLARE
x positive :=1;
max_value CONSTANT positive := 10;
begin
loop
x := x+1;
EXIT WHEN x>max_value;
END LOOP;
END;


© 2020 DotNetHeaven. All rights reserved.