Subject Re: [firebird-support] CASE syntax
Author Svein Erling Tysvaer
Hi Sergio!

I tried a similar statement to yours (though simpler) in Firebird 2.1 RC1:

select case (select rdb$relation_id from rdb$database)
when 0 then 'Zero'
when 1 then 'One'
else 'Something else'
end
from rdb$database

It gives a similar error to your statement. If I remove one line and try

select case (select rdb$relation_id from rdb$database)
when 0 then 'Zero'
else 'Something else'
end
from rdb$database

then everything works as expected. To me, this seems like a possible
error, though I've no idea whether it is a known error or something new.
Probably worth asking a question on firebird-devel? Though I don't think
you'll ever get this statement to work in Firebird 1.5.3.

Set

Sergio wrote:
> When I use the following:
>
> SELECT
> ...somefields...
> CASE (SELECT FIRST 1 T1.MyField FROM SomeTable T1
> WHERE T1.MyIndex = T.MyIndex ORDER BY T1.OrderField DESC)
> WHEN 0 THEN 'some string'
> WHEN 1 THEN 'another string'
> :
> :
> ELSE
> 'blablabla'
> END FieldAlias
> FROM
> MyTable T
> WHERE
> ...some conditions...
> ORDER BY
> 1,
> 2
>
> I receive an error: "Invalid token. invalid request BLR at offset 219.
> context already in use (BLR error)." What's wrong?