Information générale
Catégorie:
Codage, syntaxe et commandes
>I want to have a auto-number field in the multi-user environment.
>I frequently use table buffering in my input forms.
>How to eliminate duplicate key when inputting ?
I do it this way:
1. I use INTEGER keys wherever possible.
2. I have a table (LASTKEY) with just one record, holding (surprise!) the last used key number.
3. I wrote a function (GETNEXTKEY) which opens LASTKEY EXCLUSIVEly, increments the last key number, and returns that value. (Don't forget to close the table, or you will cause quite a deadlock!)
4. I specify GETNEXTKEY() as the default value for all key fields.
Note: it's OK to share the same LASTKEY for all tables, since with INTEGER fields you have more than 2 billion possible key values, and that allows me not to worry about unused key values either. (If the user starts to insert a new record but cancels it, a key value will go unused. So what?)
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement