Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Relation
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01225516
Message ID:
01225542
Vues:
25
Hi Moises,

No, I don't think that random number may prevent duplication.

In multi-user application you really need some proven algorithm to avoid two users adding the same ID at the same time.

Using NextID table is a well known generic approach for the problem.

If you do not want to use extra table for some reason, let me find you a thread I had on the exact same topic several months back.

>In my applications that are already running for long time
>and would be hard to modify, I am considering to use the code below
>
>A random number would be added to the code to prevent duplications
>
>Do you think 1 in 10,000 is good a range to prevent duplications ?
>
>**************************************
>add_code = Int(10000*Rand())
>
>dimension lctemp[1]
>select max(ap.id2) from ap ;
> into array lctemp
> lcTemp[1] = nvl(lcTemp[1],0)+1 + add_code
>replace ap.id2 with lctemp
>
>*********************************************
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform