Jamie
Jamie

Reputation: 43

Informix - IF Statement

I have the following statement for a MySQL DB.

if(cms_hagent.ti_availtime > '0',1,0) as "Total Available Time"

I need to convert it to query an Informix DB. Any suggestions on the proper syntax?

Upvotes: 2

Views: 4361

Answers (2)

A-Tech
A-Tech

Reputation: 1101

On Informix 12.10 and higher, you can use IF statements (in the context of SPL routines) directly with the following syntax:

IF [condition] THEN
[action]
ELIF [condition] THEN --optional
[action]
END IF

The documentation further states:

The expression in an IF statement can be any valid condition, as the Condition segment of the IBM® Informix® Guide to SQL: Syntax describes. For the complete syntax and a detailed discussion of the IF statement, see the IBM Informix Guide to SQL: Syntax

Upvotes: 0

peterm
peterm

Reputation: 92805

Use CASE which is part of SQL-92 standard

CASE WHEN cms_hagent.ti_availtime > '0' THEN 1 ELSE 0 END AS "Total Available Time"

Upvotes: 3

Related Questions