Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting relation - index
Message
From
17/08/2016 16:25:56
 
 
To
17/08/2016 14:43:57
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01639522
Message ID:
01639591
Views:
55
>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
Map
View

Click here to load this message in the networking platform