Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Making sure one occurence of the record is created
Message
De
25/04/2003 17:17:14
 
 
À
25/04/2003 17:06:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00781704
Message ID:
00781712
Vues:
21
hello Michel

i would do the following:
- both users look if they need to add the record
- both (at the exact time) say yes
- both try to RLOCK() (i think vfp let only one lock the record), therefor the 2nd user can get a message, exit the adding procedure, etc.

>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform