Subject RE: [firebird-support] Re: Possible to write this in a way that indices will be used
Author Sasha Matijasic
>
> Maya Opperman wrote:
> > If :IInputParam is null then
> > .. do SQL without mentioning input param
> > Else
> > .. re-do same sql, but this time add where t.Field = :IInputParam
>
> For such cases, I have a simple find&replace function that rewrites the
> query. I write statements like this:
>
> where ... { and t.Field = :IInputParam }
>
> after params are filled, the function reads the SQL statements looking
> for { } and when param inside it is NULL it removes the {...} part
> completely.
>

I agree with Milan on this. With a couple of helper functions you can easily write your own very limited query builder.
Although, when using such methods I prefer writing queries like this:

/*where*/ /*condition1: t.Field = :IinputParam*/ ...

that way i can copy the sql and paste it to flamerobin and it runs and I can uncomment any part of where clauses for testing.
In runtime it is relatively easy to use regex for replacing desired parts of query.

Sasha