Icon IF

Performs IF..ELSE type of inline expression handling.

Syntax
IF(<BooleanExpression> THEN <Expression> ELSE <Expression>)
IF(<BooleanExpression>, <Expression>, <Expression>)

<BooleanExpression> =

Type of:

BOOLEAN|BOOL
SMALLINT
INTEGER|INT
BIGINT

<Expression> =

Type of:

CHARACTER|CHAR
CHARACTER VARYING|VARCHAR
GUID
BYTE
BYTE VARYING|VARBYTE
BINARY LARGE OBJECT|BLOB
CHARACTER LARGE OBJECT|CLOB
BOOLEAN|BOOL
SMALLINT
INTEGER|INT
BIGINT
FLOAT
DECIMAL|NUMERIC
DATE
TIME
TIMESTAMP
INTERVAL YEAR
INTERVAL YEAR TO MONTH
INTERVAL MONTH
INTERVAL DAY
INTERVAL DAY TO HOUR
INTERVAL DAY TO MINUTE
INTERVAL DAY TO SECOND
INTERVAL DAY TO MSECOND
INTERVAL HOUR
INTERVAL HOUR TO MINUTE
INTERVAL HOUR TO SECOND
INTERVAL HOUR TO MSECOND
INTERVAL MINUTE
INTERVAL MINUTE TO SECOND
INTERVAL MINUTE TO MSECOND
INTERVAL SECOND
INTERVAL SECOND TO MSECOND
INTERVAL MSECOND

Returns
Same as input

Usage
The IF function performs inline IF..ELSE boolean expression handling. Both result expressions must be type-compatible. Use the CAST function to ensure that both expressions are type-compatible.

Examples
SELECT CAST(TransDateTime AS VARCHAR(25)) + ':' +
IF(Amount < 0 THEN
   '(' + CAST(Amount AS VARCHAR(20)) + ')'
ELSE
   CAST(Amount AS VARCHAR(20)))
AS Entry
FROM Transactions

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image