Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Primary key invalid error
Message
 
 
To
10/08/2000 14:40:12
Shane Gilbert
Oklahoma State Department of Education
Norman, Oklahoma, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00403568
Message ID:
00403627
Views:
11
If the problem is indeed lock ups and crashes, there won't be any solid solution. Even Stonefield can not overcome that kind of problem. My best advice is to always use table-buffered views. That way if the computer crashes, you lose only the buffered data which will provide a much better chance of not corrupting the underlying tables.

If the problem is with the server crashing then you have even fewer chances of avoiding corruption. Make sure the server has a UPS that will provide at least 15 minutes of backup power if the electricity goes off. My recommendation is using the APC brand UPS and the accompanying software, Powerchute, which will automate an unattended [and orderly] shutdown of the server if no one is around to do it manually.

Next try to figure out the cause of the lockups. Is it something in your app? Does the OS just need a fresh install along with everything else? Would a utility like RegClean help? Uninstall obsolete or unneeded software.

I too have had problems with duplicate keys but that came from a Tableupdate() problem where the PK was not generated at all so the PKs were 0. But nothing so severe that would not let me open the table to fix.

>I am getting Primary Key violations on my tables from time to time. The application is written in VFP 3.0 and uses surrogate keys of type Integer. There is a stored procedure in the database, NextId() that grabs the next ID for a record. This function is set in the default value property of the tableID field, and a Primary index is set on this field. Pretty standard stuff.

> I am having a problem with Index corruption and then the Primary Key is somehow getting reused. When I reindex the table I get the invalid primary key error and can't open the table anymore. I think the problem is caused by lock ups and crashes that corrupt the indexes. We have Stonefield Database Toolkit 3.0, but I haven't implemented it as part of the application. I just created a Datafix Utility program to fix errors. This approach is not working well, because it doesn't fix the duplicate primary key problem.

> Are there any suggestions on how to detect index corruption and deal with these problems in a better way, possibly on the fly? How can I fix the duplicate Primary Key problem automatically once it happens? I can't open the table or drop the key with this error. And if I drop the table and delete the CDX file I loose my long file names,which I could write a program to deal with, but that doesn't seem like the right way to go. Any suggestions or similar experiences would be greatly appreciated.
>
>Shane
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform