Board index » delphi » Getting a Record Count...
Michael Mount
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Getting a Record Count...Hi all, |
Michael Mount
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Getting a Record Count...Hi all, |
Derek Davidso
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Getting a Record Count...Michael Quote> I'm using D3 with SQL Anywhere and want to avoid the TQuery.RecordCount know works. However, BEWARE. RecordCount isn't always correct when used with a TQuery (in fact, it's wrong often enough to be useless). The only way I've found to get consistent results with RecordCount is to issue a .Last method call(which forces Delphi to read the entire query, row by row and, as you say, can slow things down a great deal). Quote> Thus far I've gotten screamingly fast response by doing a "SELECT Quote> TQuery.RecNo always gives me -1 (which, although it is a lovely number, databases like dBase. Derek Davidson (Remove the x to EMail me : der...@mksoft.com) |
Michael Moun
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Getting a Record Count...QuoteDerek Davidson wrote: Quote> SELECT COUNT(*) is the right way to go, I'm afraid ask you how to start a new thread when executing the Count(*), but (with one "T"), do you think it would be better to execute this on a thread, rather than in-process as I am now - the "Test" query returned a count of 44,000 records in a "might-as-well-have-been-instantaneous" time frame but will that degrade with complex joins and selection criteria? Quote> Derek Davidson |
Andrew Holland
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Getting a Record Count...This is a multi-part message in MIME format. QuoteDerek Davidson wrote: true. However, each database vendor ususally has some support for this sort of thing. In Oracle, there are "pseudocolumns" you can query upon. ROWNUM will return you the sequential count of a row within the current query set. Ie, to get the first 10 records that match a query, use AND ROWNUM < 10 or to set unique id number in a table use SET someidcolumn = ROWID in an update statement. Note that ROWNUM is relative to the current query only, not to the position of the record in the physical db table. Thus, you can not use it in the WHERE part of a update statement for example. But if you know you will be getting 100 rows and your current rownumber is 50, its a good bet you are half way through your query result. Also of note is that ROWNUM values are assigned *before* an ORDER BY affects the sort of a query, which may or may not help you... The other is ROWID. This returns a *unique* id value for a particular XXXXXXX:YYYYYY:ZZZZZ where ZZZZ is the physical datafile index (usually 1) and Consider this ROWID value: 0000000F.0000.0002 The row corresponding to I am not a user of SQLServer, so I can not comment on similar features begin: vcard --------------DBF99C0F16A23D142975DFF2-- |
Derek Davidso
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Getting a Record Count...Andrew I recalled that Oracle had such a feature (non-ANSI) but it still Derek Davidson (Remove the x to EMail me : der...@mksoft.com) |
Derek Davidso
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Getting a Record Count...Michael Quote> I'm using Delphi 3 Professional - Is there another option? version without 3rd party libraries. Quote> Do you think it would be better to execute this on a thread, in-process Quote> the "Test" query returned a count Derek Davidson (Remove the x to EMail me : der...@mksoft.com) |
1. Getting record count of detail table
2. getting the count of records in a filtered query
3. Record count excluding deleted records
4. Delphi 4 + Native Ms Access 97 driver + Filtered dataset + record count/record number
5. How to get Record Count of a Detail Record in DBGrid
6. presenting records while getting records...
7. Getting a count of the GROUP BY
8. Getting word count from word using Delphi