Switch PL/SQL

PL/SQL Case Statement:

The Switch statement executes a block of statements based on the switch expression value. An expression must be of type int, short, byte, or char. A case value should be a constant literal value and cannot be duplicated. The expression value is compared with each case value. If a match is found, a corresponding block of statements will be executed. A break statement is used to terminate the execution of statements. If no case value matches the expression value, then the default block of statements will be executed. If a break statement is not used within the case, all matching cases will be executed.

Syntax:

CASE [expression]  
WHEN condition1 THEN Block of statements1  
   WHEN condition2 THEN Block of statements2
   ...  
   WHEN conditionn THEN Block of statementsn
 ELSE Block of statements  
END   

Example:

DECLARE
   nameChar char(1) := 'J';
BEGIN
   CASE nameChar
      when 'B' then dbms_output.put_line('Bharat');
      when 'R' then dbms_output.put_line('Richi');
      when 'S' then dbms_output.put_line('Sahdev');
      when 'V' then dbms_output.put_line('Vinod');
      when 'H' then dbms_output.put_line('Harish');
      when 'M' then dbms_output.put_line('Mahesh');
      when 'V' then dbms_output.put_line('Vivek');
      when 'A' then dbms_output.put_line('Anil');
      when 'J' then dbms_output.put_line('Jai');
      else dbms_output.put_line('No such name');
   END CASE;
END;
/

Output:

Jai