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.
|
Tip: To change the maximum size for new segments in an existing workspace, use the AW command with the SEGMENTSIZE keyword. To discover the current maximum size for new segments, use the AW function with the SEGMENTSIZE keyword. |
Return Value
The data type of the first result argument.
Syntax
DECODE (expr , search, result [, search , result]... [, default])
Arguments
The expression to be searched. The function automatically converts expr to the data type of the first search value before comparing
An expression to search for. The function automatically each search value to the data type of the first search value before comparing
The expression to return when expression is equal to search.
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.