Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique integer id value?
Message
De
07/04/1997 03:26:02
 
 
À
06/04/1997 14:10:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00027200
Message ID:
00027229
Vues:
40
>I use SUBSTR(SYS(2015),3,10) as a unique id all through my system. I started this because I understood it is based on the present time which to me seems to be always unique.
>
>Now I am considering using integers because I heard that SEEKing and ORDERing is quicker with them.
>
>Is there an equivalent expression that results in a unique integer?


The first function can run into trouble. What happens if two people hit at exactly the same time? Or in fall fall when Standard Time begins and you set the clocks back an hour and the people working the graveyard shift have the 1:00 am hour twice?

I use a table to store the next ID, then increment it:

LPARAMETER tcTable

LOCAL lnArea, lnRetVal

lnArea = SELECT()

IF !USED("Keys")
USE Keys IN 0
ENDIF

SELECT Keys
LOCATE FOR UPPER(Table( = UPPER(tcTable)
DO WHILE !FLOCK()
ENDDO

lnRetVal = NextKey
REPLACE NextKey WITH NextKey + 1
UNLOCK

SELECT (lnArea)
RETURN lnRetVal


Craig
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