Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Conversion Functions
 

Using the DECODE() Function

DECODE(value, search_value, result, default_value) compares value with search_value. If the values are equal, DECODE() returns result, otherwise default_value is returned. DECODE() allows you to perform if-then-else logic in SQL without having to use PL/SQL. SQL> SELECT DECODE(1, 1, 2, 3)   2  FROM dual; DECODE(1,1,2,3) ---------------               2 SQL>