Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sequential numbers
Message
De
22/11/2002 11:18:29
 
 
À
22/11/2002 11:04:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00725809
Message ID:
00725821
Vues:
18
There is a chance that a duplicate number be generated if another user increment the counter while the current line executing is between UNLOCK and RETURN key_no.NUMERO

A safer approach will be:
LOCAL lnReturnValue
< SNIP >
REPLACE Numero WITH Numero + 1
lnReturnValue = Key_No.Numero
UNLOCK
SELECT (lnOldSel)
RETURN lnReturnValue
HTH

>I use the following code to create sequential numbers compliments of Michael.
>The code has worked fine until the last several days where it is creating duplicate numbers.
>LOCAL lnOldSel,lnCompteur
>lnOldSel=SELECT()
>lnCompteur=0
>IF ! USED('key_no')
> USE key_no IN 0
>ENDIF
>SELECT key_no
>
>DO WHILE (NOT RLOCK()) AND (INKEY(0.1)=0) AND lnCompteur<=25
>   lnCompteur=lnCompteur+1
>ENDDO
>REPLACE NUMERO WITH NUMERO+1
>UNLOCK
>SELECT(lnOldSel)
>RETURN key_no.NUMERO
>The server is Windows 2000 server and using VFP 7.0.
>
>Any idea what may be happening or is there an inherent flaw in the code.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform