4.11 EVAL

Allows the user to select a value depending on a series of independent tests. There is no practical limit to the number of conditions. If the number of cases is large, it is beneficial to list the most frequently encountered conditions first.

Syntax

@EVAL (condition1, result1 [, condition2, result2] [, ...] 
[, default_result])
condition

A conditional test using standard conditional operators.

result

A value or string to return based on the results of the conditional test. Enclose literals within double quotes.

default_result

A default result to return if none of the conditions is satisfied. A default result is optional.

Examples

Example 1   

In the following example, if AMOUNT is greater than 10000, "high amount" is returned. If AMOUNT is greater than 5000 (and less than or equal to 10000), "somewhat high" is returned (unless the prior condition was satisfied). If neither condition is satisfied, a COLUMN_MISSING indicator is returned because a default result is not specified.

AMOUNT_DESC = @EVAL (AMOUNT > 10000, "high amount", AMOUNT > 5000, 
"somewhat high")
Example 2   

The following is a modification of the preceding example. It returns the same results, except that a default value is specified, and a result of "lower" is returned if AMOUNT is less than or equal to 5000.

@EVAL (AMOUNT > 10000, "high amount", AMOUNT > 5000, "somewhat high", "lower")