Subject RecordCount (for IBO v4) (or sooner if you like)
Author Jason Wharton
Here is what I would like to do about record count. Sorry if this is a
little rambly.

First of all, I cannot remove it because it is built into the TDataset base
class. I am forced to implement something for it.

That said, I would like to change what I have done in the past as it has led
to some confusion. Here's what I did and why.

If you are working polymorphically with the TDataset level RecordCount
property (e.g. MyDataSource.Dataset.RecordCount) you are mapped via the
getter method to the virtual function GetRecordCount. Thus, the
TDataset.RecordCount property is implemented by overriding this method. I
did this but only using an algorithm to look at the records in the buffer
and making sure to at least detect if one whole row only existed.

Since the DBGrid control directly accesses this property as described I must
have friendly code in this method or I will impose some serious performance
problems for people's applications. I do realize that I can tell the grid to
be ignorant of the record count but then the scrollbars are not accurate as
I like them to be. This is controlled by the IsSequenced function in the
TDataset class.

MyIBODataset.RecordCount <> TDataset( MyIBODataset ).RecordCount

The only way they would be the same is if all records were fetched into the
buffer.

What I did at the TIBODataset level is to redefine the RecordCount property
to hook into the "real" record count instead of just a peek at the number of
records in the buffer. This is confusing I think. I now think I should not
redefine the RecordCount property but that I should leave it just as it is
and separately implement a function called RecordCountQuery of type longint.
This will deliver the full record if that is what the developer wants.

Now, in order to be exactly compliant with what the BDE did with TQuery and
TTable I am considering adding a property to control the mode of the
built-in RecordCount property. I believe I can set a property that will
toggle the behavior of the dataset with regard to the grid. This is
controlled by the virtual function called:

function TDataSet.IsSequenced: Boolean;
begin
Result := True;
end;

And for TQuery when using InterBase this returns false but I leave it to
true in IBO is why I've had to fiddle with the RecordCount property. Leaving
this as true gives the accurate scrollbar with TDBGrid and I like that but I
realize that this isn't exactly what the BDE did.

I will make TIBOQuery and TIBOTable do just what the BDE did (even though I
prefer otherwise) and then I will document that it is possible to use the
way that I prefer things and explain the full ramifications of doing it.
Which are, if you say IsSequenced is true then the RecordCount property will
deliver the quick report by looking at the buffers and if IsSequenced is
false then RecordCount will do the full blown record count as it does with
TQuery (only I will use a more efficient way).

How does this sound? Is it clear enough to understand? How will this affect
InfoPower and other 3rd party tools?

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