Board index » delphi » Incorrect Count in IBX

Incorrect Count in IBX

I have noticed that after upgrade some of the IBDataSets return
RecordCount=1 after the query is opened?? any reason behind it?

Regards
Paul

 

Re:Incorrect Count in IBX


Did you fetch your records?
I always thought that TIBQuery.RecordCount return the number
of fetched records, but the actual number of records in set.
Quote
PR wrote:
> I have noticed that after upgrade some of the IBDataSets return
> RecordCount=1 after the query is opened?? any reason behind it?

> Regards
> Paul

Re:Incorrect Count in IBX


I thought that opening the IbDataSet or IbQuery will automatically fetche
records affected by the query, right?

regards
Paul

Re:Incorrect Count in IBX


In that case, what for is FetchAll method in TIBCustomDataset?

Jeff wrote (not so long ago) :
"IBX only pulls data when you request each record.  It does not do a
FetchAll when opening."

Quote
PR wrote:
> I thought that opening the IbDataSet or IbQuery will automatically fetche
> records affected by the query, right?

> regards
> Paul

Re:Incorrect Count in IBX


Quote
PR wrote:

> I have noticed that after upgrade some of the IBDataSets return
> RecordCount=1 after the query is opened?? any reason behind it?

        That's the way that IBX is designed.  RecordCount is always a bad idea
with C/S databases, because to get an accurate count of the records you
need to fetch all records in the selection, which can involve
substantial overhead.  IBX is just telling you how many records have
been fetched.

        Use SELECT COUNT(*) in a separate query if you must know how many
records are in a selection, and make sure the query uses an index!  IBO
does this automatically, but I actually do not like that feature,
because it encourages people to use RecordCount...

Quote
> I thought that opening the IbDataSet or IbQuery will automatically fetche
> records affected by the query, right?

        No, but I can understand why this might be confusing, because the BDE
does do a FetchAll when you look at the RecordCount property.  This is
one of the reasons that RecordCount is not good for C/S work.

        HTH,

        -Craig

--
Craig Stuntz            Vertex Systems Corporation
Senior Developer        http://www.vertexsoftware.com

Other Threads