Subject Re: [IBO] SQL Error code = -804
Author Jason Wharton
> >First, a quickie: What is the "proper" way to test for "is the result
set
> >empty?"
> > RowsSelected, RowsAffected, EOF and BOF, try..except, or ??
>
> Test the .IsEmpty property.

If you are using a buffered query then IsEmpty is the best. This is because
it pertains to the buffer containing any records or is it empty.

If you are using a unidirectional dataset then call the First method (and
not Open) and check for Eof.

> >Second,
> >
> >This seems to be a simple, direct TIB_DSQL, but on the 2nd execution of
it
> >(and thereafter), I receive:
> >
> >SQL Error code = -804
> >SQLDA missing or incorrect version, or incorrect number/type of
variables.
>
> You cannot get a dataset back from a TIB_DSQL - it is for executing
statements. Here you are calling Execute on a SELECT statement. You will
also get this error from calling Open instead of Execute or ExecSQL on a
statement that performs a DSQL operation.
>
> If you want to SELECT rows, use TIB_Cursor or TIB_Query.

Actually, the TIB_DSQL component is ideal for doing a singleton fetch which
appears to be what he is doing. Unfortunately, this is the famous bug in
InterBase haunting us yet some more.

The most efficient work around is to use a TIB_Cursor and call the First
method and check for Eof to see if there is a record or not. Then, if you
want to make sure there was only a single record you have to call Next and
check for Eof again. The second fetch will be cheap since IB batches them
together anyway.

HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com