Subject RE: [IBO] How to know if a query is empty with an IB_Cursor
Author Jason Wharton
> With MyCursor do begin
> Close ;
> SQL.Text := 'SELECT ... WHERE ID = :ID' ;
> ParamByName('ID').AsInt64 := id ; // id is a parameter of my function
> Prepare ;
> First ;
> Result := not (EOF and BOF) ;
> end ;

When you call ParamByName() the dataset is prepared automatically so there
is not actually a need to call Prepare explicitly and whenever you alter the
SQL property the dataset is closed and unprepared automatically.

Having it in code though is good for clarity and readability for others that
may not be familiar with IBO but I just wanted you to know the internal
behavior a little better. IBO lets your code be a bit sloppy I guess.

This is how you should do it:

With MyCursor do begin
Close;
Unprepare;
SQL.Text := 'SELECT ... WHERE ID = :ID' ;
Prepare;
AutoFetchAll := false;
ParamByName('ID').AsInt64 := id ; // id is a parameter of my function
First ;
Result := not EOF ;
end ;

Regards,
Jason Wharton