Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
vchu asked how to write an IF-style conditional in Informix SQL. Art Kagel supplied a SELECT CASE WHEN ... THEN ... ELSE ... END example, which vchu accepted. Malcolm added that the result column is named (expression) unless an alias is given after END, which matters when parsing output or loading a temp table.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Can someone help me to convert something like this in Informix SQL?
select
when arriveDT > appointmentDT then "OT"
when arriveDT <= appointmentDT then "Normal"
else "unknown"
from contract
thanks
vchu
--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums.aspx/informix/200804/1
vchu via DBMonster.com wrote:
> Can someone help me to convert something like this in Informix SQL?
>
> select
> when arriveDT > appointmentDT then "OT"
> when arriveDT <= appointmentDT then "Normal"
> else "unknown"
> from contract
>
> thanks
> vchu
Not so different:
select
case
when arriveDT > appointmentDT then "OT"
when arriveDT <= appointmentDT then "Normal"
else "unknown"
end
from contract;
Art S. Kagel
Oninit
thanks a lots :)
Art S. Kagel (Oninit) wrote:
>> Can someone help me to convert something like this in Informix SQL?
>>
>[quoted text clipped - 6 lines]
>> thanks
>> vchu
>Not so different:
>
>select
> case
> when arriveDT > appointmentDT then "OT"
> when arriveDT <= appointmentDT then "Normal"
> else "unknown"
> end
>from contract;
>
>Art S. Kagel
>Oninit
--
Message posted via http://www.dbmonster.com
On 11 Apr, 17:05, "Art S. Kagel (Oninit)" <a...@oninit.com> wrote:
> vchu via DBMonster.com wrote:
> > Can someone help me to convert something like this in Informix SQL?
>
> > select
> > when arriveDT > appointmentDT then "OT"
> > when arriveDT <= appointmentDT then "Normal"
> > else "unknown"
> > from contract
>
> > thanks
> > vchu
>
> Not so different:
>
> select
> case
> when arriveDT > appointmentDT then "OT"
> when arriveDT <= appointmentDT then "Normal"
> else "unknown"
> end
> from contract;
>
> Art S. Kagel
> Oninit
Just a tiny note: if you're parsing your output, or want to put it
into a temp table, you'll need to specify a name for the returned
value (Informix will just return "(expression)" as the identifier.
Just add your preferred identifier to the 'end' statement, e.g.
select
case
<stuff>
end arriveDT_status
from contract
(or whatever you want to call it).
Malc
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.