PW01-L05 · Direct rewrite

Conditional value

Replace SQL IIF with the CEL conditional operator.

ProjectWise-specific
Migration outcome

Rewrite a simple branch and recognise the difference between = and ==.

ProjectWise context

General expression in ProjectWise CEL

SQL functionLegacy ProjectWise configuration
IIF(500 < 1000, 'YES', 'NO')
CELProjectWise CEL
500 < 1000 ? 'YES' : 'NO'

What is different

CEL uses condition ? true-value : false-value. The value of the selected branch becomes the result of the expression.

  1. IIF is a SQL function call, while CEL uses a language operator.
  2. For equality, CEL uses == rather than SQL =.
  3. Both branches should return compatible types.

Migration goal

Select one of two values from a boolean condition.

What changes

SQL writes the branch as an IIF call. CEL uses a conditional operator with the condition before the question mark.

Why the CEL solution is clearer

The expression exposes three parts: condition, true result, and false result. In a real rewrite, remember that CEL equality uses ==.

Before deployment

Test both branches. If one branch dereferences a null object, the expression may still fail for a particular input.

Sources

  • BENTLEY-PW-CEL-SQL-FUNCTIONS — official IIF mapping.