|Subject||RE: [firebird-support] part of statements optional|
>From: Walter Ogston [mailto:ogstoncw@...]My bad, to make it clear I simplified my problem to much. But it is true your solution solves this specific case reasonably well but it is not a solution for the general case where I want to make portions of SELECT statements dependant on parameters.
>>In the simplest form I am asking for a way to have different where clauses
>>in select statements for instance.
>>Select * from table
>> If (condition) then
>> where a=b
>> where b=b
>Gotta drag my mind back to discrete math, boolean algebra etc. Does
> (condition and (a=b)) or (not condition and (c=b))
>do what you want?
What I was really looking for in this case was mainly to have the order by clause depending on the parameter (I have solved my where clause issues with coalesce).
So the remaining real problem looks like this
Select * from table
If (condition) then
Order by a
order by b
In MsSQL I think you can write it like this:
ORDER BY CASE WHEN condition a END ASC,
CASE WHEN condition b END ASC
I am sorry I simplified the first question into stupidity but I am still interested in an answer to the general question. Right now I have two large separate Select statements, this is both error prone and ugly.