Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Go bottom
Message
De
16/10/2004 12:02:12
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
15/10/2004 16:12:54
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00950231
Message ID:
00951946
Vues:
12
>Mohammed
>
>You got answers that will work but you are not asking the right question.
>
>Don't use MAX() to get the next number. It is better to generate next number.

Now since it's a Saturday and I have some time on my hands, here goes the general list of good and valid reasons for this:

- max() will give the next number based on what's already in the table. If two users request the max before either of them writes, they'll get the same number. And that will cause duplicate keys (which may be handy if you lock your keys in the car, but not so nice in a database situation).

- max() will not see any deleted or filtered-out records. If the last record is deleted (the last user just found out that record with the key 16 is bad, and decided to delete it and start over), max() will not see it and will produce 15 again. Also, if any of Set Filter To, Set Order To {index with a FOR clause} or Set Key To is in effect, it will calculate the max() from visible records only.

Therefore, an independent counter is the solution, Q.E.D.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform