Developer Documentation Library > UNICOM Intelligence Function Library > Miscellaneous functions > Decode
 
Decode
Provides the same functionality as an IF-THEN-ELSE statement (used for OnNextCase events).
Syntax
Decode(<expression>, <search>, <result>, ... [,<default_value>])
Parameter
There are variable pairs for <search> and Result.
<expression>
Type: None
The value to compare.
<search>
Type: None
The value that is compared against Expression.
<result>
Type: None
The returned value if Expression is equal to <search>.
<default_value>
Type: None
If no matches are found, it returns the default. If the default value is omitted, then the decode statement returns null.
Notes
The function searches <expression> and returns the related <result> if <search> is found. Otherwise, the function returns <default_value>. If <default_value> is not set, the function returns null.
There are restrictions when using this function:
<expression> can include the following types: Long, Double, Text, Date, Categorical, Boolean.
<expression> and <search> must be the same data type.
Example
Decode(Expression, "USA", "America",
"UK", "UnitedKindom",
"OtherCountries")
The following table shows the <expression> and retrieved result values:
Expression
Result by Decode()
"USA"
"America"
"UK"
"UnitedKindom"
"German"
"OtherCountries"
Decode(Expression, 1, "Red",
2, "Yellow")
The following table shows the Expression and retrieved result values:
Expression
Result by Decode()
1
"Red"
2
"Yellow"
3
null
See also
Miscellaneous functions