ORACLE/PLSQL: DECODE FUNCTION This Oracle tutorial explains how to use the Oracle/PLSQL DECODE functionwith syntax and examples.
DESCRIPTION The Oracle/PLSQL DECODE function has the functionality of an IFTHENELSE statement.
SYNTAX The syntax for the Oracle/PLSQL DECODE function is: DECODE( expression , search , result [, search , result]... [, default] )
Parameters or Arguments expression is the value to compare. search is the value that is compared against expression. result is the value returned, if expression is equal to search. default is optional. If no matches are found, the DECODE function will returndefault. If default is omitted, then the DECODE function will return null (if no matches are found).
APPLIES TO The DECODE function can be used in the following versions of Oracle/PLSQL: Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i
EXAMPLE The DECODE function can be used in Oracle/PLSQL. You could use the DECODE function in a SQL statement as follows: