Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why reccount() and _tally are different ?
Message
 
To
08/05/1998 09:23:08
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00097511
Message ID:
00098267
Views:
53
>>So, RECCOUNT() returns the number of the records in the current area, which is the one of the result set. BUT, the result set may be only a filter on the real table, so, the RECCOUNT() may return in fact the number of records in the real table (similar to a table that has an active filter). If the result is a real cursor, RECCOUNT returns the same thing as _TALLY.
>
>I have NEVER seen or had this happen, and if it does I feel it is a bug.
>
>BOb
Bob,

This is not a bug it is by design. FoxPro optimizes the query and gets the result in the fastest possible way. That may be to;

USE TheTable AGAIN ALIAS MyCursor IN 0
SET FILTER TO

in this optimized fashion RECCOUNT() and _TALLY will not match.

As a matter of fact;

USE MyTable
DELETE ALL FOR RECNO()%2=0
SET DELETED ON
?RECCOUNT()

will give you the original record count before the deletions because RECCOUNT() returns the record count from the dbf header which is the actual number of records in the table and it has nothing to do with deleted or not.

The solution to living with this behavior is to use _TALLY when you want to know the number of records in your result and RECCOUNT() when you need to kow the size of the file your are dealing with.
Previous
Reply
Map
View

Click here to load this message in the networking platform