Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generating New Primary Keys
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00013582
Message ID:
00013597
Views:
29
>Question came up on Darcy Whites listserv and thought I'd throw it around here.
>
>What is best way to generate a new primary key?
>
>I use a udf that stores the pointer, and order. Then sets the order to the primary tag, then goes bottom and increments, then returns order and pointer and returns back new key. Fairly fast udf since it doesn't do any locate etc but if anyone has better code/ideas let me know.
>
>TIA

The inheritant problem with your method is what happens if two people do an add at the same time. If you don't mind skipped values, you can use a different table to hold the keys, then FLOCK() the file, get the key, increment it, UNLOCK and return.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform