Subject | Re: [firebird-support] Re: where field = any |
---|---|
Author | Miroslav Penchev |
Post date | 2004-10-21T16:59:06Z |
On Thu, 21 Oct 2004 02:13:24 -0300, Alexandre Benson Smith
<iblist@...> wrote:
not just AND's. This can be solved with "template" of the statement and so
on...
--
Miroslav Penchev
<iblist@...> wrote:
>Yea, that is a way to do it. But some time WHERE clause is more complex,
> Miroslav Penchev wrote:
>
> If this is the case, just make it on the fly:
>
> procedure MakeFilter;
>
> procedure AddWhere(var aWhere:String const aCondition:string);
> begin
> if aWhere <> '' then
> aWhere := aWhere + ' and ';
>
> aWhere := aWhere + aCondition;
> end;
>
> var
> wSQL, wWhere:String;
>
> begin
> wSQL := 'Select * from aTable';
>
> wWhere := '';
>
> if CheckBoxName.Checked then
> AddWhere(wWhere, 'Name = ''blablabla''')
>
> if CheckBoxCity.Checked then
> AddWhere(wWhere, 'City = ''blablabla''')
>
> ....
>
> if wWhere <> '' then
> wSQL := wSQL + ' where ' + wWhere;
>
> MyQuery.SQL.Text := wSQL;
> MyQuery.Open;
> ...
> end;
>
> If it will be dynamic, just make it dynamic.
>
> Just be carefull for table aliases and ambiguous column names if you
> will do joins (or use views instead).
not just AND's. This can be solved with "template" of the statement and so
on...
--
Miroslav Penchev