Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More on candidate key
Message
From
26/04/2003 00:36:37
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
More on candidate key
Miscellaneous
Thread ID:
00781792
Message ID:
00781792
Views:
54
Ok, in regards to the candidate key thread created tonight about the ability to assure that no duplicate records would be created, based on the combination of two fields that have to be unique, I would like to add a few feedback.

That approach is much more robust, for avoiding a combination of duplicate fields, than the original approach. However, it's not perfect.

The problem with the candidate key, combined with TRY/CATCH, is that it will assure that no combination of two fields will happen but only when data has been entered. Having said that, I mean that at creation time, when the INSERT INTO is invoked, the record is created but blank values are present. Thus, another user doing the same INSERT INTO will cause a failure of candidate key. Two records got created at the same time with blank values and that means, that from this point, we can no longer add any new record as a uniqueness of candidate key error will be fired by VFP.

So, we need to work on top of this existence approach to see what would be the best way to take care of this last possibility.

One way could be to use the master table which holds all the primary keys of all tables and apply a lock on that record before doing the process. So, while the lock is present, no additional process could be done from the same loop. However, I don't like that. So, any other solution would be welcome.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform