Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need help with a primary key
Message
From
10/06/2001 23:11:53
 
 
To
08/06/2001 15:46:23
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00517080
Message ID:
00517614
Views:
11
Hi David,

SNIP
>
>I just tested it with a program that uses a FOR NEXT loop to insert 20,000 records into a small table using SYS(2015) to generate a key. Two concurrent FoxPro sessions running this program simultaneously on a 866 Mhz PIII machine generated 33 duplicates. So I would say that this method is not good in a multiuser environment where keys are being generated very rapidly (Hundreds or more per second).
>
>Or trap the duplicate key error and try it again. That may be the best solution. I little slower, but more reliable.

Your test proves that it can present a problem but your conclusion that keys being generated very rapidly (hundreds or more per second) is incorrect.
It really only takes a two pC setup and two simultaneous actions for the case to occur. And in fact the actions do not technically have to be simultaneous - only the factors that cause the duplication need to occur simultaneously. For instance, if the result of SYS(2015) is dependent on the time then it seems possible that one machine with its clock exactly 5 minutes offset from the other could have the action done exactly 5 minutes later and still hit the problem.

Regards,

JimN
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform