How to Use IF ELSE Statement in PL/SQL
In this article I am going to explain how to use if else statement in PL/SQL.
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
IF ELSE statement in PL/SQL is the most basic of all the control flow statements. If ELSE statement execute a sequence of statement depending upon condition.
There are three types of IF statements
st_id CONSTANT NUMBER(10) := 2;
st_marks CONSTANT NUMBER :=60;
BEGINIF (st_marks>80) THEN
st_grade := 'A';
ELSIF (st_marks>60) THEN
st_grade := 'B';
ELSIF (st_marks>40) THEN
st_grade := 'C';
st_grade := 'Fail';
insert into marks_info values(st_id, st_marks, st_grade);
Statement that show data from marks_info table