IF expressions

The syntax of the IF expression is as follows:

IF condition
THEN expression1
[ ELSE expression2 ]
{ ENDIF | END IF }

This expression returns the following:

  • If condition is TRUE, the IF expression returns expression1.
  • If condition is FALSE, the IF expression returns expression2.
  • If condition is FALSE, and there is no expression2, the IF expression returns NULL.
  • If condition is UNKNOWN, the IF expression returns NULL.

condition is any valid search condition. See Search conditions.

For more information about TRUE, FALSE and UNKNOWN conditions, see NULL value, and Search conditions.

IF statement is different from IF expression

The IF expression is not the same as the IF statement. For information about the IF statement, see IF statement.