Skip Headers

Oracle® OLAP DML Reference
10g Release 1 (10.1)

Part Number B10339-02
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page

Go to previous page
Go to next page
View PDF


The DECODE function compares one expression to one or more other expressions and, when the base expression is equal to a search expression, returns the corresponding result expression; or, when no match is found, returns the default expression when it is specified, or NA when it is not.

Return Value

The data type of the first search argument.


DECODE (expr , search, result [, search , result]... [, default])



The expression to be searched.


An expression to search for.


The expression to return when expression is equal to search.


An expression to return when expression is not equal to search.


Order of Value Evaluation

The search, result, and default values can be derived from expressions. The function evaluates each search value only before comparing it to expr, rather than evaluating all search values before comparing any of them with expr. Consequently, the function never evaluates a search when a previous search is equal to expr.

Automatic Data Type Conversion Before Searching for Values

The function automatically converts expr and each search value to the data type of the first search value before comparing. The function automatically converts the return value to the same data type as the first result.

Decoding NA Values

The DECODE function considers two NAs to be equivalent. When expr is NA, then the function returns the result of the first search that is also NA.