%OPR_IIF%
Uses the IIF function and expands an expression in an expression macro to evaluate a set of IIF statements.
Syntax
%OPR_IIF[ condition, macro_input_field [,value ]]%
The following table describes the arguments for this function:
Argument | Required/ Optional | Description |
---|
condition | Required | The condition you want to evaluate. You can enter any valid expression that evaluates to TRUE or FALSE. You can enter a macro input field or an expression that includes at least one macro input field. |
macro_input_field | Required | The values you want to return if the condition is TRUE. Any datatype except Binary. The return value is the datatype specified by this argument. You can enter a macro input field or an expression that includes at least one macro input field. |
value | Optional | The value you want to return if the condition is FALSE. Any datatype except Binary. You can enter any valid expression, but do not enter a macro input field. |
Unlike conditional functions in some systems, the FALSE (value) condition in the %OPR_IIF% function is not required. If you omit value, the function returns the following values when the condition is FALSE:
- •Zero if macro_input_field is a Numeric datatype.
- •Empty string if macro_input_field is a String datatype.
- •NULL if macro_input_field is a Date/Time datatype.
Return Value
macro_input_field if the condition is TRUE.
value if the condition is FALSE.
If the data contains multibyte characters and the condition argument compares string data, the return value depends on the code page of the Secure Agent that runs the task.
%OPR_IIF% and Datatypes
When you use %OPR_IIF%, the datatype of the return value is the same as the datatype of the result with the greatest precision.
When at least one result is Double, the datatype of the return value is Double.
Example
The following macro input fields %tmin% and %tmax% create ranges that correspond to the following %type% macro input field:
%tmin% | %tmax% | %type% |
---|
0 | 30 | very cold |
31 | 60 | cold |
61 | 90 | warm |
91 | 100 | hot |
101 | 150 | very hot |
The following expression assigns a type based on the temperature data:
%OPR_IIF [ (TEMP >= %tmin%) AND (TEMP <= %tmax%), '%type%', 'out of range' ]%
%OPR_IIF% evaluates the following temperatures and returns a type:
TEMP | RETURN VALUE |
---|
79 | warm |
21 | very cold |
170 | out of range |
99 | hot |
90 | warm |