Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error C0000005 on CALCULATE CNT() of a large table 1

Status
Not open for further replies.

albertdc

Programmer
Feb 10, 2004
38
PH
The error always occurs at the same point of the code with the same table involved.
 
table is 500mb

the code below is in a procedure that repeatedly called for each table in the folder.

SELECT (lcAlias)

?'Counting records...'
CALCULATE CNT() TO lnCount
IF _TALLY = 0
lnCount = 0
ENDIF

USE IN (lcAlias)

using vfp6 sp5 under Win2k Pro

we already tried the ff. statements but always fails on that particularl table everytime:

CALCULATE CNT() TO ARRAY laCount
COUNT TO lnCount
SELECT COUNT(.T.) FROM (lcAlias) INTO ARRAY laCount
 
Maybe this will help.
Although you'll need to catch fpt, "not a dbf",
and dbf names with embedded spaces(if you make a copy
using windows explorer and forget about it) errors.

Code:
set deleted off
local cPath, nDbfs, i, cTmpCurs
local array aDbfs[1]

cTmpCurs = sys(2015)
cPath = "c:\somepath\"
nDbfs = adir(aDbfs,cPath+"*.dbf")

for i = 1 to nDbfs

  use cPath+aDbfs[i,1] in 1 noupdate

  select (field(1,alias(1))) ;
      from (alias(1)) where deleted() ;
      into cursor (cTmpCurs)

  ? reccount(alias(1)) - reccount(cTmpCurs)

  use in (cTmpCurs)
  use in alias(1)
next
 
This should be faster and maybe it won't gag on your 500MB table.

Code:
set deleted off
local cPath, nDbfs, i, nDels
local array aDbfs[1]

cPath = "c:\somepath\"
nDbfs = adir(aDbfs,cPath+"*.dbf")

for i = 1 to nDbfs
  use cPath+aDbfs[i,1] noupdate
  calculate cnt() for deleted() to nDels
  ? reccount() - nDels
  use
next
 
thanks for ur suggestions! i'll try them both and let u know the results.
 
the NOUPDATE keyword seems to be the answer. i reverted to using CALCULATE CNT() TO ARRAY lnCount without further errors.
 
FYI, Darrell:

The DBF's with embedded spaces in their file names are easy to deal with. In your code, just change the line:
Code:
use cPath+aDbfs[i,1] in 1 noupdate
to
Code:
use (cPath+aDbfs[i,1]) in 1 noupdate

The parentheses cause VFP to use a "name expression" instead of a literal name. It may even work without the parentheses, since vfp would then be using an implicit "name expression", though vfp may end up looking for a file named "cPath+aDbfs[i,1]" since that is a legal file name.

- Bill

Get the best answers to your questions -- See FAQ481-4875.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top