Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Avoiding Dublicate Field entries in a multi-user applica
Message
De
20/02/1998 12:49:28
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/02/1998 12:30:03
Allen Hanna
H. A. Hanna Associates
Indianola, Indiana, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00080125
Message ID:
00080145
Vues:
33
Snip..
>>First I wouldn't suggest recno() as a PK. Assuming still you want it :
Snip..
>>Cetin
>
>Here's another method I've used. The advantage is that you don't have to do extra record locking and keep track of last-used ID's. The disadvantage is that you don't get sequential numbers.
>
>Store julian date or year+month+day in the order number field. Then add the 24-hour time with seconds. The format would be YYYYMMDDHHmmSS. If you're indexed on this field, everything will be in date/time order. If you have a lot of users, you may want to add a couple of digits from the random number generator, Rand(), to avoid two people hitting the Enter key at the same second.
>
>But, If you need sequential numbers or need to follow an existing format, you can't use this method.
>
>Allen
Hi Allen,
Of course this is better. To shorten it and directly use as a default value you could use sys(2015). It would give a 10 char unique value for a given station and would be unique even called via a program :
v1 = sys(2015)
v2 = sys(2015)
v3 = sys(2015)
? v1,v2,v3
It's based on system datetime. So unless the datetime of computer is set to a previous datetime, there is no chance to get a duplicate on a given computer. For multiple computers on a LAN, fortunately network card addresses are unique, and they are represented in 12 bytes. So sys(2015)+netcardaddress would ensure a unique key on a LAN.
BTW: You could get netcardaddress via WinAPI but don't know the function. I use my own asm routine.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform