Subject Re: [firebird-support] using case in order by statement in sp
Author Helen Borrie
At 07:29 PM 30/05/2007, you wrote:
>Hi - I'm in the process of converting a number of SPs from an
>If..Then..Else construct to a Case... construct because in a number of
>them the only part which changes is the index.
>Using FB 1.5.3 Windows 2003 server and IB Expert. Lots of ram and disk.
>
>This works (and has already been applied to a number of SPs)
>
>order by case when (:indexby)=0 then Supp_Name /* name index
> else Supp_Code end /* code index

I don't think so. ORDER BY is structural in a SP, i.e. it has to be
concrete at compile time....unless you are talking about assembling a
string to pass to EXECUTE STATEMENT, of course. If not, then what
evidence do you have that it works? I'd be worried to know that the
parser allowed it...

./heLen