Looks like CASE isn't allowed in the version of Informix we're currently running. Fortunately, we're upgrading soon!
The best I've come up with so far goes like this:
select 'xyz' as mycola
from mytable
Where cola = 1
union
select 'abc'
where colb = 2
union
select 'def'
where colb != 2
and cola != 1
I suspect I won't do any better than that, unless perhaps I start creating stored procedures....
Main Topics
Browse All Topics





by: LowfatspreadPosted on 2007-04-17 at 15:43:03ID: 18928059
like this...
e Statement
select case when cola = 1 then 'xyz' when colb = 2 then 'abc' else 'def' end as mycola
from (select case q when 1 then 'x' when 2 then 'y' else null end as colq
, x.*
from mytable as x) as a
Where colz = case when coly = 3 then 4 when colw = 5 then 9 else 0 end
basically case has 2 formats
case (expression) when Value then (expression) else (expression) end
or
case when (expression) then (Expression) else (expression) end
expression can include nested case statements...
If cannot be used within the Select/Insert/Update/Delet
its a procedural language construct...
If Exists (select x from tablea where cola = 1)
begin
do.....
end
hth
Not familiar with exact Informix SQL..i