Oracle SQL,PL/SQL

What is a case statement in PL/SQL?

What is a case statement in PL/SQL? | TechTweet
Avatar of shohal
Written by shohal

case statement in PL/SQL

A CASE statement is similar to IF-THEN-ELSIF statement.

That selects one alternative based on the condition from the available options.

CASE statement uses “selector” rather than a Boolean expression to choose the sequence.

Execute a sequence of statements based on a selector.

How many type is case statement in pl/sql?

Two types:

(1)Simple CASE statement

(2)Searched CASE statement.

PL/SQL Case Structure :

What is a case statement in PL/SQL? | TechTweet
What is a case statement in PL/SQL? | TechTweet

Simple CASE statement

Declare
f_rank varchar2(10); 
b_grade char(1); 
 begin 
 b_grade :='b';
case b_grade 
when 'a' then 
f_rank :='very good'; 
when 'b' then 
f_rank :='good';
else
f_rank :='no such grade'; 
 end case; 
dbms_output.put_line(f_rank); 
end; 
SQL> /
good 
• 
PL/SQL procedure successfully completed.

Searched CASE statement

 declare
 d_sales NUMBER;
 c_commission NUMBER;
Begin 
 d_sales :=150000; 
  case
 when d_sales >200000 then 
c_commission := 0.1;
when d_sales >10000 then
c_commission := 0.2; 
else
 c_commission := 0; 
end case;
 dbms_output.put_line('commission is' || c_commission *100 ||'%');
end;
SQL> /
 commission is20%
 •
 PL/SQL procedure successfully completed.

About the author

Avatar of shohal

shohal

I have profession and personal attachment with custom ERP Software development, Business Analysis, Project Management and Implementation almost (36) ,also Oracle Apex is my all-time favorite platform to developed the software. Moreover i have some website development experience with WordPress. For hand on networking experience DevOps and CCNA, it create me a full package. Here are some core programming language with networking course i have been worked: Oracle SQL ,PL/SQL,Oracle 19c Database , Oracle Apex 20.1,WordPress,Asp.Net ,MS SQL ,CCNA ,Dev Ops, SAP SD

Leave a Comment