Subject | RE: [IBO] How to know if a query is empty with an IB_Cursor |
---|---|
Author | Jason Wharton |
Post date | 2005-12-29T17:51:42Z |
> With MyCursor do beginWhen you call ParamByName() the dataset is prepared automatically so there
> 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 ;
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