Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 Tags
Subject: RE: RECCOUNT() - is there other way??
Thread ID: 50646 Message ID: 50689 # Views: 5 # Ratings: 0
Version: Visual FoxPro 8 Category: Other
Date: Saturday, September 04, 2004 5:27:24 PM         
   


> Hi Jefferson
>
> > Is there another way of returning the total number of records in a
> > table than RECCOUNT()?
> > The problem with RECCOUNT() is it also includes the records marked
> > for deletion, which i dont really need.
> > Is there a way (aside from looping)? Or have just i omitted a command??
>
> You can do it a number of ways, the only question is whether you care about moving the record pointer in the table or not.
>
> If you don't want to move the record pointer, then use SQL:
>
> SELECT COUNT(*) FROM table WHERE NOT DELETED() INTO ARRAY laJunk
> lnRex = laJunk[1]
> 

>
> If you don't mind using the record pointer, and want a quicker result then use native VFP:
>
> COUNT FOR NOT DELETED() TO lnRex
> 

>
>
>
> Regards
> Andy Kramek
> Microsoft MVP (Visual FoxPro)
> Akron, OH, USA


Hi,
Unfortunately, all the ways above in a very large table say 1-2 million records will take time.
The Reccount () function returns the physical number of records, and as we all know deleting
a record does not remove it until a pack is performed. This means there is no way to obtain the
number of records in a table without using a SQL type of command, or a count type of command.
I do not have the knowledge of the internal workings of VFP, but lets play how this could be done:
- CDX's with a filter set on the index expression "delete()=.F." show only non-deleted records. The
deleted ones are filtered out. So if MS wanted, they could with their knowledge write a function to
access the CDX and scan for non-deleted counts in a CDX such as described above. This would run
a lot faster than scanning the real table. However, no such function exists....lol
Pete from the Great White North. (Only in Canada, ay.) Over and Out ...


ENTIRE THREAD

RECCOUNT() - is there other way?? Posted by Jefferson Aguilar @ 9/4/2004 8:28:56 AM
RE: RECCOUNT() - is there other way?? Posted by Eric den Doop @ 9/4/2004 11:15:41 AM
RE: RECCOUNT() - is there other way?? Posted by Jefferson Aguilar @ 9/5/2004 11:18:25 AM
RE: RECCOUNT() - is there other way?? Posted by Boudewijn Lutgerink @ 9/4/2004 11:20:53 AM
RE: RECCOUNT() - is there other way?? Posted by Jefferson Aguilar @ 9/5/2004 11:30:05 AM
RE: RECCOUNT() - is there other way?? Posted by Boudewijn Lutgerink @ 9/6/2004 7:12:08 AM
RE: RECCOUNT() - is there other way?? Posted by Andy Kramek @ 9/4/2004 1:24:34 PM
RE: RECCOUNT() - is there other way?? Posted by Pete Sass @ 9/4/2004 5:27:24 PM
RE: RECCOUNT() - is there other way?? Posted by Jefferson Aguilar @ 9/5/2004 11:44:37 AM
RE: RECCOUNT() - is there other way?? Posted by Jefferson Aguilar @ 9/5/2004 11:38:28 AM