|
Question: How to obtain a correct number of records in TpFIBDataSet?
Answer: FIBPlus works with the server at the level of SQL queries. The server does not return the record number to the client after the SELECT query, because all the records are retrieved one after another by the Fetch method.
In practice we know the number of records fetched only when the server reports that there are no more records in the query result after the regular Fetch.
The simplest thing you can do to obtain the correct number of records in the TpFIBDataSet is to use the poFetchAll option. After opening the query you should check the RecordCount value (it will be correct) or to use the psAskRecordCount option. If psAskRecordCount = True, then after opening SelectSQL TpFIBDataSet will automatically execute a supplementary query "SELECT count(*)" in order to make the server report about the record number.
This mechanism does not guarantee correct work because the COUNT() use is restricted by InterBase/Firebird features.
Besides sometimes FIBPlus cannot convert the main query from SelectSQL (it can be very complex) into a simple query which will only get the record number.
Such a behaviour is common for any InterBase/Firebird library.
We are a small software company with thousands of customers delivering comany wide systems including accounting, logistics, e-commerce, POS, sales etc etc. Several years ago, when we were still a very small company, we used Delphi 3 and Paradox combined with BDE. As our system (and customer base) grew I decided to switch to Delphi 5 and Interbase. Being a huge improvement over Delphi 3 and Paradox, I encountered numerous problems with IBX: memory leaks, performance issues and other problems. Borland was not to be bothered: IBX was provided "as is" and no support was avaliable.