Case with else : Case « PL SQL « Oracle PL / SQL






Case with else

 

SQL>
SQL> -- case with else
SQL>
SQL> declare
  2    l_num number := 8;
  3  begin
  4    case l_num
  5      when 1 then dbms_output.put_line('You selected one');
  6      when 2 then dbms_output.put_line('You selected two');
  7      when 3 then dbms_output.put_line('You selected three');
  8      when 4 then dbms_output.put_line('You selected four');
  9      when 5 then dbms_output.put_line('You selected five');
 10      when 6 then dbms_output.put_line('You selected six');
 11      when 7 then dbms_output.put_line('You selected seven');
 12      when 8 then dbms_output.put_line('You selected eight');
 13      when 9 then dbms_output.put_line('You selected nine');
 14      when 0 then dbms_output.put_line('You selected zero');
 15      else dbms_output.put_line('You selected more than one digit...');
 16    end case;
 17  end;
 18  /
You selected eight

PL/SQL procedure successfully completed.

SQL>
           
         
  








Related examples in the same category

1.Simple case demo
2.Case conditions
3.CASE WHEN statement with variable
4.CASE WHEN with constant
5.CASE not found while executing CASE statement
6.This CASE statement is labeled
7.CASE WHEN with comparison operator
8.Uses a NUMBER datatype as the selector
9.Output discount rate based on different category