Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a New User Defined Primary Key
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00420360
Message ID:
00420404
Views:
15
>>>>>>>>>>>>>>>>>>>>>>>>
In an Client-Server application where the customer insists on a specific Primary key (say ID C(10)), I wish to discuss the pros and cons of the following methods of inserting a new record.

(a) Check if the new primary key (Say ID = "JFK"), exists in the Backend table using INDEXSEEK or SELECT-SQL, then lock the WHOLE table while the INSERT is being performed.
(b) Try to insert the record without checking, trap and deal with any error returned ie "Duplicate Primary key"
(c) Any other suggestions?
>>>>>>>>>>>>>>>>>>>>>>>>>

I recommend B. Most folks I know use this approach -- it will be difficult to get A to work with 100% accuracy, and even if you do it will be slower.

BTW, it may be worth considering a different, non-business-meaningful primary key, and setting up your ID field as a candidate key. Depending on the data entgine, and the size of the key used, joins against the true-primary-key will be quicker.
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell
Previous
Reply
Map
View

Click here to load this message in the networking platform