Subject | RE: [IBO] Re: Adding search criteria to WHERE clause and more..not working as expected. |
---|---|
Author | Adrian Wreyford |
Post date | 2007-01-13T16:46:54Z |
Thanks Michael
It works .. but still not sure why. I think it works as follows?
So it appears the SQLWhere clause only holds the Search SQL that was
assigned, but when the SQL for the Query is prepared for sending to the
server for execution, then the SQLWhereItemsAdd part you assigned so
elegantly, is actually added to the where clause.
Again .. Thanks for the prompt and complete answer!
Adrian
_____
Michael Wrote:
Declare an OnPrepareSQL event handler:
procedure <suitable object>.RestrictToDOB(Sender: TObject);
begin
(Sender as TIBODataset).SQLWhereItems.Add('ANIMAL.ANIMALDOB
BETWEEN ''' +
DateToStr(DTPBeg.Date) + ''' AND ''' + DateToStr(DTPEnd.Date)
+ ''' ');
end;
Then assign it:
IBOQuery1.OnPrepareSQL := <instance of the suitable
object>.RestrictToDOB;
I don't think you need to do this Prepare any more:
result of this).
[Non-text portions of this message have been removed]
It works .. but still not sure why. I think it works as follows?
So it appears the SQLWhere clause only holds the Search SQL that was
assigned, but when the SQL for the Query is prepared for sending to the
server for execution, then the SQLWhereItemsAdd part you assigned so
elegantly, is actually added to the where clause.
Again .. Thanks for the prompt and complete answer!
Adrian
_____
Michael Wrote:
Declare an OnPrepareSQL event handler:
procedure <suitable object>.RestrictToDOB(Sender: TObject);
begin
(Sender as TIBODataset).SQLWhereItems.Add('ANIMAL.ANIMALDOB
BETWEEN ''' +
DateToStr(DTPBeg.Date) + ''' AND ''' + DateToStr(DTPEnd.Date)
+ ''' ');
end;
Then assign it:
IBOQuery1.OnPrepareSQL := <instance of the suitable
object>.RestrictToDOB;
I don't think you need to do this Prepare any more:
>Do this, though (I think the OnPrepareSql event gets called as a
> IBOQuery1.Prepare;
>
result of this).
> IBOQuery1.AssignSQLWithSearch(IB_Query1);Michael D. Spence
> IBOQuery1.Open;
>
[Non-text portions of this message have been removed]