Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting a unique sequential ID for a record
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00812087
Message ID:
00812106
Vues:
12
Look at http://www.craigberntson.com/Articles/kb006.htm

>The following code was written for VFP5 a few years ago. Either the customer never noticed there was a problem, or it's just started acting up, but when I was testing it last week, it kept ending up with duplicate record ID.
>...
> set deleted on
> set reprocess to 30 seconds
> use sel_control in 0 exclusive && this is a single record table
> current_request_id=sel_control.next_request
> replace sel_control.next_request with current_request_id+1
> use
> close all
> set exclusive off
>...
>later on in the code
>* Create the main request row for the request_id
> m.request_id = m.current_request_id
> m.fieldxxx ....
> m.fieldyyy = ... etc.
>...
> insert into sel_request from memvar
>At this point it fails sometimes, and will not do the insert, because request_id which is supposed to be a unique field in this table ahs already been used. However, the first piece of code should have incremented it by one, each time.
>
>This was failing, when only one user was on the system, so it's not from too many multiple users.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform