Hello,
1. According to the "TMSDataSetOptions.QueryRecCount Property" topic in help, QueryRecCount should work with these options:
FetchAll=True
NonBlocking=True
But it does not. It only works with FetchAll=False.
Did I misunderstood something?
2. Like QueryRecCount, we want to execute a query before opening the dataset to find some aggregates.
E.g: SELECT SUM(COL1), SUM(COL2), MIN(COL3) FROM (MSQuery.BaseSQL) AS T1
I think QueryRecCount runs a similar SQL:
SELECT COUNT(*) FROM (MSQuery.BaseSQL) AS T1
We want to execute a single SQL and get all the results in a single run: SELECT COUNT(*), SUM(COL1).....
Is there a way to set the RecordCount property manually like QueryRecCount does?
Or is it possible to implement a custom TMSQuery to modify the QueryRecCount's SQL text and behavior?
3. With FetchAll=False and QueryRecCount=True,
how can we find the number of fetched rows so far?
Thanks.
QueryRecCount
1. The QueryRecCount property works if FetchAll is False or NonBlocking is True. If FetchAll is True, you get control only after fetching all records, and in this case you get a record count without any additional query.
2. If FetchAll is True, TCustomDADataSet performs additional query to get record count for the opened SQL query and you don't need to do it yourself.
3. If QueryRecCount is True, you can't get the number of fetched rows.
2. If FetchAll is True, TCustomDADataSet performs additional query to get record count for the opened SQL query and you don't need to do it yourself.
3. If QueryRecCount is True, you can't get the number of fetched rows.
Thanks for the reply, but your answers did not help.
As far as we see, QueryRecCount has some problems.
For example, when you delete a record with the Dataset.Delete method the recordcount remains same if QueryRecCount is True.
To solve the problem we derived a custom TMSQuery and override
the GetRecordCount event of TDataSet. It works even with FetchAll=True and NonBlocking=True !
We have tested this in many different cases and it works OK.
Could there be any side effects of this implementation?
Thanks.
As far as we see, QueryRecCount has some problems.
For example, when you delete a record with the Dataset.Delete method the recordcount remains same if QueryRecCount is True.
To solve the problem we derived a custom TMSQuery and override
the GetRecordCount event of TDataSet. It works even with FetchAll=True and NonBlocking=True !
We have tested this in many different cases and it works OK.
Could there be any side effects of this implementation?
Thanks.
The GetRecordCount is overriden and it is simple:
In the DoBeforeOpen method, FgioRecordCount is set by the result of a query.
Then in AfterDelete and AfterPost events FgioRecordCount is decreased or increased.
Code: Select all
if FgioQueryRecCount then
Result := FgioRecordCount
else
Result := inherited GetRecordCount;Then in AfterDelete and AfterPost events FgioRecordCount is decreased or increased.
I can not reproduce the problem. Please, try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.Zoner wrote:As far as we see, QueryRecCount has some problems.
For example, when you delete a record with the Dataset.Delete method the recordcount remains same if QueryRecCount is True.