Subject | using case in order by statement in sp |
---|---|
Author | Alan.Davies@aldis-systems.co.uk |
Post date | 2007-05-30T09:29:41Z |
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
But if I need more than one column as an index I get parsing errors
and cannot compile. I guess its an issue with the case.. begin.. end
This does not work
order by case when (:indexby)=0 then
begin
S.Supp_Code,F.Farm_Name /* name index
end
else begin
S.Supp_Code,F.Farm_Code /* code index
end
end
Any suggestions please?
Regards
Alan
--
Alan J Davies
Aldis
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
But if I need more than one column as an index I get parsing errors
and cannot compile. I guess its an issue with the case.. begin.. end
This does not work
order by case when (:indexby)=0 then
begin
S.Supp_Code,F.Farm_Name /* name index
end
else begin
S.Supp_Code,F.Farm_Code /* code index
end
end
Any suggestions please?
Regards
Alan
--
Alan J Davies
Aldis