CASE WHEN with comparison operator : Case « PL SQL « Oracle PL / SQL






CASE WHEN with comparison operator

  
SQL>
SQL> DECLARE
  2    v_Test1 NUMBER := 2;
  3    v_Test2 VARCHAR2(20) := 'Goodbye';
  4  BEGIN
  5    CASE
  6      WHEN v_Test1 = 1 THEN
  7        DBMS_OUTPUT.PUT_LINE('One!');
  8        DBMS_OUTPUT.PUT_LINE('Another one!');
  9      WHEN v_Test1 > 1 THEN
 10        DBMS_OUTPUT.PUT_LINE('> 1!');
 11        DBMS_OUTPUT.PUT_LINE('Still > 1!');
 12      WHEN v_Test2 = 'Goodbye' THEN
 13        DBMS_OUTPUT.PUT_LINE('Goodbye!');
 14        DBMS_OUTPUT.PUT_LINE('Adios!');
 15      ELSE
 16        DBMS_OUTPUT.PUT_LINE('No match');
 17    END CASE;
 18  END;
 19  /
> 1!
Still > 1!

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.Uses a NUMBER datatype as the selector
9.Output discount rate based on different category