General information
Category:
Coding, syntax & commands
Title:
Reccount() that accounts for deleted records...
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only