IFF(expression, trueresult [, falseresult ])
expression | A conditional expression. |
trueresult | The result to return when the expression is true. This may be any expression or action. |
falseresult | The result to return when the expression is false. This may be any expression or action. This may be omitted only if the result is an action. |
Return: | IF returns a single value, set, recordset, or action. |
The IFF function performs the same functionality as IF, but ensures that an expression containing complex boolean logic is evaluated exactly as it appears.
The main difference between IF and IFF is with conditional scalar expressions. Generally the arguments to dataset IF() operators are always evaluated lazily, but there are situations, if the expression type is a row or a scalar, where they might not be.
For example:
foo := IF (age < 18, '', expensiveFunction());
Then there is no guarantee that expensiveFunction will not be executed. If you use IFF() the code generator internally converts it to a dataset expression, ensuring it is evaluated lazily.