General information
Category:
Coding, syntax & commands
>Thank you for your input, Sir - always appreciated!
John,
as a matter of fact I just, by accident found following by Christoff, think you will find it usefull to read:
quote
REINDEX is a bad idea, nonetheless. In order to create a brand new CDX file, Visual FoxPro has to move the old CDX file out of the way. For a short moment the table exists without a CDX file. A moment short enough, though, to causes malfunctioning. When REINDEX cancels out due to an error, it does not restore the previous CDX file. As the following sample demonstrates, you end up with an indexless table:
Create Cursor curDemo (cID C(1))
Insert into curDemo Values ("A")
Insert into curDemo Values ("B")
Index on GetID(cID) Tag cID CANDIDATE
? ">", Key(1)
Reindex
? ">", Key(1)
plKill = .T.
Reindex
? ">", Key(1)
Procedure GetID(tcID)
If Vartype(m.plKill) == "L"
Return "A"
Else
Return m.tcID
EndIf
EndProc
Run this program and ignore the error message. You can see that KEY(1) returns a valid expression the first two times, but nothing the last time. If you had used a table you would notice that the CDX file is gone. That's only a problem when you encounter an error during the index operation. Aside from problems with memory and network connections, you might encounter errors on CANDIDATE and PRIMARY indexes when you
added an index without letting check VFP existing data,
ran into some sort of index corruption that allowed VFP to add multiple records with the same key, or
have an index on a function that is causing an error.
In any case, it's probably better to avoid these problems and just don't use REINDEX in a production application.
unquote
Regards,
Koen
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only