Uses a NUMBER datatype as the selector : Case « PL SQL « Oracle PL / SQL






Uses a NUMBER datatype as the selector

    
SQL>
SQL> DECLARE
  2    selector NUMBER := 0;
  3  BEGIN
  4    CASE selector
  5      WHEN 0 THEN
  6        dbms_output.put_line('Case 0!');
  7      WHEN 1 THEN
  8        dbms_output.put_line('Case 1!');
  9      ELSE
 10        dbms_output.put_line('No match!');
 11    END CASE;
 12  END;
 13  /
Case 0!

PL/SQL procedure successfully completed.

SQL>
SQL>

   
    
    
    
  








Related examples in the same category

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