Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reccount() that accounts for deleted records...
Message
From
05/01/2003 21:38:46
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Reccount() that accounts for deleted records...
Miscellaneous
Thread ID:
00738269
Message ID:
00738269
Views:
55
When SET DELETED is "ON", RECCOUNT() by design still returns the total number of records in the table. I have had for a long time a dire need for second parameter on RECCOUNT() to return the number of records not including those that are deleted. I created a function called RECCOUNTD, and it works great 99% of the time. When tables exceed several hundred thousand records lags of 5-10 seconds or more can be seen the first time the function is called on the table. Here is my code:

FUNCTION ReccountD
PARAMETERS Reccount_WhichDB

** REMEMBER THAT THIS FUNCTION DOES NOT CLEAR FILTERS!!!!!!!

** STORE ENVIRONMENT
Reccount_OldSel = SELECT()

IF NOT EMPTY(Reccount_WhichDB)
SELECT (Reccount_WhichDB)
ENDIF
Reccount_OldRecNo = RECNO()

IF Reccount_OldRecNo > 0
COUNT TO Reccount_Return

** RESET ENVIRONMENT
=GoRec(Reccount_OldRecNo)
SELECT (Reccount_OldSel)

RETURN Reccount_Return
ELSE
** RESET ENVIRONMENT
SELECT (Reccount_OldSel)
RETURN 0
ENDIF


** END CODE

Originally, I used SELECT COUNT(*) code, but it was ultimately slower for some reason and this code also accounted for filters (something that I desired).

Does anyone have any optimization ideas and/or is there any chance that MS can whip up a "COUNT()" function that tells how many records are in the current view if you were essentially to browse the table.

Thanks,

JohnO
Next
Reply
Map
View

Click here to load this message in the networking platform