Thread: FoxPro Some General Questions/Index does match the table

Index does match the table
Original

Does adding a dummy record, deleting it, and then issuing a pack and reindex fix it?

I once read an article on foxite about it recommending an on-the-fly fix (I don't have a link to the article anymore but I have my notes):

Create a cross-reference free table to save all of the indexing parameters:

1. Table name
2. List of all fields for each table
3. Names of index tags for each field
4. Index key for each tag

Create an error trap routine using the standard ON ERROR DO ErrHandler WITH syntax and trap for error 114. When it traps for that error it should run a function such as RepairCDX(qcDBF) that rebuilds the index based on the entries in the table you cross-reference table you created above or delete the cdx and reacreate using something similar.

For free tables, we do something similar. We have a program that creates another function that we can call that knows the table structure and indices for each table. We then backup the original table, delete it and the index file, and run the functions passing the tablename and it creates a new table and index on the fly. We append the records from the backup. For tables that belong to a database, we have recently started using SDT and are very happy with it.



Problem with FoxPro indexes (some discussion over on the WIKI):
CDXBloat  
Index Corruption  
Persistent Index Corruption
CDXCorruption Checklist