View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0012238||FPC||Database||public||2008-09-26 15:12||2014-02-18 11:02|
|Reporter||pomalo||Assigned To||Joost van der Sluis|
|Product Version||Product Build|
|Target Version||Fixed in Version|
|Summary||0012238: TSQLQuery.RecordCount returns wrong value when dataset is filtered|
|Description||see attached sample|
|Tags||No tags attached.|
|Fixed in Revision|
test_filter.zip (4,993 bytes)
Can you tell me some more? I can not run your example, offcourse. Because I do not have your database.
It is much easier if you can tell me what the problem is. Does it have something to do with filtering?
Do you know that recordcount only shows the amount of records in memory? So that you have to do a .movelast befor a recordcount to get the complete recordset in memory?
||when a dataset is filtered, recordcount return the number of record before filtering not the recordcount from the filtered dataset|
Ok, thanks. That will be difficult to fix, though.
And I'm not sure if Delphi/other database-components can do this.
||Please post a full compilable example with the database|
If sb interested see it, it would be very interesting to know if Delphi implements this.
If so, recordcount on a filtered dataset should trigger the filtering I guess.
I just hit the same problem as the reporter and i found that Delphi has the same behavior of sqldb. So seems not a bug.
I've raised another issue that *may* be related (or then again, may not). However, over there, there is at least a test case that reproduces RecordCount not changing after a filter is applied.
I did test in Delphi XE (with TClientDataSet and TADODataSet) and it seems to me, that RecordCount CHANGES after activating Filter!
Can somebody else confirm it, as above mentioned links says, that in Delphi (lesser version?) RecordCount does not change after filtering ?
Last edited: 2013-12-17 11:42
If you can read Dutch: at least in 2009 (don't know what Delphi versions were used) the recordcount changes on TClientDataset:
I'd say that changing recordcount based on filter seems like a reasonable thing to do, especially as more recent Delphi versions do the same anyway.
(The delphigroups link Luiz posted apparently uses BDE, not clientdataset/any vaguely recent dataset, so I think we can discount that one)
Delphi XE5 dataset.recordcount documentations specifies it returns -1 as a fallback and descendents are free to implement their own versions.
testRecordCount.dpr (2,243 bytes)
I did again tests with TClientDataset in D7 and DXE and RecordCount reflects Filter (and also OnFilterRecord if used)
See attached testRecordCount.dpr
- Calculated fields are not supported in filter expression
- User defined OnFilterRecord is not called on each usage of RecordCount (so I guess, that there must be some mechanism of caching "FilteredRecordCount" which is calculated once when filter is activatd and later only updated)
- When records are added/updated, RecordCount changes as records fit or fit not in filter criteria
- RecNo reflects Filter and is No. of record after filter is applied
|2008-09-26 15:12||pomalo||New Issue|
|2008-09-26 15:12||pomalo||File Added: test_filter.zip|
|2008-09-26 15:12||pomalo||Widgetset||=> Win32|
|2008-09-26 15:18||Vincent Snijders||Project||Packages => FPC|
|2008-09-26 15:33||Jonas Maebe||Status||new => assigned|
|2008-09-26 15:33||Jonas Maebe||Assigned To||=> Joost van der Sluis|
|2008-11-26 18:00||Joost van der Sluis||Note Added: 0023580|
|2008-11-26 18:00||Joost van der Sluis||Status||assigned => feedback|
|2008-11-26 22:33||pomalo||Note Added: 0023589|
|2008-11-27 11:58||Joost van der Sluis||Note Added: 0023601|
|2008-11-27 11:59||Joost van der Sluis||Status||feedback => acknowledged|
|2008-12-01 14:52||Joost van der Sluis||FPCOldBugId||=> 0|
|2008-12-01 14:52||Joost van der Sluis||Severity||minor => feature|
|2008-12-01 14:52||Joost van der Sluis||Product Version||0.9.25 (SVN) =>|
|2010-07-21 11:01||Felipe Monteiro de Carvalho||Note Added: 0039527|
|2010-07-21 11:01||Felipe Monteiro de Carvalho||Status||acknowledged => feedback|
|2011-05-09 18:10||Joost van der Sluis||Summary||TSQLQuery.RecordCount return wrong value => TSQLQuery.RecordCount returns wrong value when dataset is filtered|
|2012-03-17 15:20||Marco van de Voort||Note Added: 0057773|
|2012-06-09 05:48||Luiz Americo||Note Added: 0060388|
|2013-09-19 07:38||Mike Thompson||Note Added: 0070182|
|2013-09-26 09:39||LacaK||Note Added: 0070340|
||Note Added: 0071933|
||Note Edited: 0071933||View Revisions|
||Note Edited: 0071933||View Revisions|
|2014-02-18 10:34||LacaK||File Added: testRecordCount.dpr|
|2014-02-18 10:40||LacaK||Note Added: 0073127|
|2014-02-18 11:02||LacaK||Note Edited: 0073127||View Revisions|