Skip Headers

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

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

Go to previous page
Previous
Go to next page
Next
View PDF

DECODE

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.

Syntax

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

Arguments

expr

The expression to be searched.

search

An expression to search for.

result

The expression to return when expression is equal to search.

default

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

Notes


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.