Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Efficient counting of recs with duplicate key fields
Message
From
13/06/1999 21:14:43
 
 
To
13/06/1999 19:54:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00229225
Message ID:
00229323
Views:
19
David ---

Yeah, sorry, use FOR not WHILE unless using SET ORDER TO .... hmmmm .... as to using SET FILTER TO ... generally inadvisable but you can always run tests on your particular table and see what happens.


>>SEEK vVal TAG KeyTagName
>>COUNT TO nDupes WHILE keyfield = vVal
>>
>>This doesn't mess up your index order, is optimizable (well, that depends on your key expression), and should be faster as it doesn't create a cursor.
>>
>
>If you mean that a completely different tag order is active, I'm not sure why the above works, since records having keyname=vVal would not necessarily be >contiguous< with respect to the ordering by another key, and the WHILE would fail before all dups are encountered.
>
>If the above really does work when ordered by a completely different key I'd have to say that the WHILE clause is a little counterintuitive. Substituting FOR for WHILE fixes it, I think?!
>
>What I was really trying to figure out is whether "searching by filtering" buys you anything or hurts you if you have a big file. The following:
>
>SET FILTER TO keyfield=vVAL
>COUNT ALL
>
>seems pretty sexy to me, but I'm aware that underlying implementation can sometimes take all the fun out of 'clever' solutions! That's why I asked the question in the first place.
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Reply
Map
View

Click here to load this message in the networking platform