Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check that Indexes has been Corrupted?
Message
 
To
12/03/2002 13:35:27
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00630529
Message ID:
00632342
Views:
21
>Good points. Is this a utility you'd be willing to make more commercial?

It's not rocket science... is a some code which illustrates it. It besides checking for index corruption it also keeps track of missing numbers (DTS - Document Tracking Numbers). A missing DTS number means a document wasn't entered into the document tracking system.
*!* Thisform.cmdGaps.RightClick()
* This method looks for skipped dts numbers in the dts table, and looks for a corrupt index.
* It stores missing numbers, if any, in \data\dtskip.txt
LOCAL lMissingArray,nNext, nHandle, fMissing, nPriorNum, cTxtFile
LOCAL nStartNum
ThisForm.OptGrpIndexes.Option1.Click()
fMissing = .F.
nStartNum = INT(VAL(ThisForm.txtFind.VALUE))
cTxtFile = gcDefaultDir + "\data\dtskip.txt" 
nHandle = FCREATE(cTxtFile,0)
IF nHandle = -1
  Wait "Can't open " + cTxtFile Window
  RETURN
ENDIF
ON ERROR FCLOSE(nHandle)
*ThisForm.MousePointer=11
SELECT DTS
SET ORDER TO TAG DTSNUM
IF nStartNum = 0
  LOCATE
  SKIP	&& the first two records are temp records. skip them
  SKIP
ELSE
  SET NEAR ON
  =SEEK(nStartNum,"DTS","DTSNUM")
  SET NEAR OFF
ENDIF
nNext = DTS.DTSNUM + 1	&& load what should be next number in sequence
DO WHILE NOT EOF("DTS")
  WAIT STR(DTS.DTSNUM) WINDOW NOWAIT
  IF DTS.DTSNUM > nNext	&& a gap exists, save number and set missing flag
    DO WHILE DTS.DTSNUM > nNext
      =FPUTS(nHandle,STR(nNext))
      nNext = nNext + 1
    ENDDO
    fMissing = .T.
  ELSE	&& no gap, set next expected number, save cur number as priornum
    nNext = DTS.DTSNUM + 1
    nPriorNum = DTS.DTSNUM
    SKIP
    IF DTS.DTSNUM < nPriorNum  AND NOT EOF("DTS")  
      * number out of sequence!
      fMissing = .T.	
      =FPUTS(nHandle,"DTS table and/or index is corrupt")
      EXIT
    ENDIF
  ENDIF
ENDDO
IF fMissing = .F.
  =FPUTS(nHandle,"No Gaps found in DTS")
ENDIF
=FCLOSE(nHandle)
ON ERROR
WAIT CLEAR
IF fMissing = .F.
=MESSAGEBOX("No Gaps found in DTS")
  RETURN
ENDIF
CD (gcDefaultDir +"\data")
temp = gcDefaultDir+"\DATA\dtskip.txt"
RUN /N C:\Program Files\Accessories\WORDPAD.EXE &temp
CD (gcDefaultDir)
Hope it is of some help.
JLK
Nebraska Dept of Revenue
Previous
Reply
Map
View

Click here to load this message in the networking platform