Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making sure one occurence of the record is created
Message
From
25/04/2003 17:13:53
 
 
To
25/04/2003 17:06:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00781704
Message ID:
00781709
Views:
15
Michel --

Can you establish a primary key for the table and trap the error in the case that a second person/process attempts to create a duplicate key?

Jay

>I have a situation where I am looking for the best approach. I need to assure that only a specific record (based on a combination of fields) is created in a table. So, before doing the INSERT INTO command I am looking into the table to see if a specific user has created a record for a specific primary key field ID. If those two values are matching a record, we don't proceed to add it in there as it's already there.
>
>The problem I have is that two users can issue the same command as the same time. So, when both are executing the LOCATE in the table to find the record, it is not there. So, both users go into the condition and the INSERT INTO is involved. However, that creates a duplicate record. I'm looking for the best to assure that this won't happen.
>
>I need to avoid doing a FLOCK(). I'm looking for another approach.
>
>This is also different that locking a record, such as getting the next primary key as this is a process that need to lock it at the table level.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform