Subject part of statements optional
Author Tim Gahnström
I have spent some time looking around for ways to make part of select statements optional it has turned up solutions for some DB:s but not for firebird so I would like to check with you that it is truly not available.

In the simplest form I am asking for a way to have different where clauses in select statements for instance.

Something like this works:

If (condition) then
Select * from table where a=b
Else
Select * from table where c=b

But it turns ugly which big select statements using lots of tables and out parameters.

So something like the below would save a lot of typing and sources of errors.

Select * from table
If (condition) then
where a=b
else
where b=b

To me it seems reasonably easy to implement in its simplest form where it is just a syntactic sugar for the first version.

Instead of me having to type the long version I think the compiler should create all the messy copy/pasting.

I have found out about the case statement but it doesn't seem to be what I am looking for and I have also seen that it is doable with dynamic SQL but that has its drawbacks both in terms of cleanliness and speed.

Is there no such feature or have I just missed something obvious?

Tim