IIF()

Available in: DSQL, PSQL

Added in: 2.0

Description

IIF takes three arguments. If the first evaluates to true, the second argument is returned; otherwise the third is returned.

Result type: Depends on input.

Syntax

 IIF (<condition>, ResultT, ResultF)

 <condition> ::= A Boolean expression.

Example

 select iif( sex = 'M', 'Sir', 'Madam' ) from Customers

IIF(Cond, Result1, Result2) is a shortcut for CASE WHEN Cond THEN Result1 ELSE Result2 END. You can also compare IIF to the ternary "? :" operator in C-like languages.

See also:
CASE
COALESCE()
NULLIF()
DECODE()
ibec_IIF
Firebird 2.0.4. Release Notes: IIF expression syntax added

back to top of page
<< HASH() | FB 2.5 Language Reference | LEFT() >>
<< HASH() | FB 2.1 Language Reference | LEFT() >>
<< GEN_ID() | FB 2.0 Language Reference | LOWER() >>