Subject Re: [IBO] is dataset empty
Author Helen Borrie
At 03:01 AM 6/01/2004 +0100, you wrote:
>Hello Luc,
>
> >>>> how to emulate IsEmpty for TIB_Dataset ?
>
> >>> For TIB_Cursors I use: EOF AND BOF.
> >>> If this is true, it's empty.
>
> > Of course I'll do a FIRST first ;-)
> >
> > In fact it always looks like:
> >
> > with myCursor do
> > begin
> > if not Prepared then Prepare;
> > First;
> > if EOF AND BOF then ...
>
>Ah - I see: First behaves differently from APIFirst in this
>respect. After APIFirst on an empty dataset, Eof is true but
>Bof false.
>
>Anyhow, after a First (or an APIFirst) testing for Eof alone should
>suffice: if the set has records, you'll be at the first one and
>Eof = false.
>
> > AutoFetchAll is NEVER set to true with my Cursors.
>
>Same here. I wonder would would happen if you'd set it to true - guess
>you would miss the entire set?

The test would be pointless. Presumably, you want to know whether the
query returns one or more rows. There is no buffer for IB_Cursor so all
you really have is BOF() (no rows returned yet) and the current row
buffer. Past the current row buffer is EOF(). Neither BOF or EOF is on
the row buffer.

Lucas' test for ib_cursor is valid *after* calling First or Next. Any
other kind of test for IsEmpty doesn't make any sense. The mistake in the
original question was to look for a way to emulate buffered behaviour in a
non-buffered dataset. That begs the question, why use ib_cursor if you
need a buffered dataset?

my .00002 cents
Helen