Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto ID Field
Message
De
22/04/1998 03:12:46
 
 
À
22/04/1998 01:03:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00093850
Message ID:
00093915
Vues:
32
Robert,

There are problems with using Sys(2015). First, if you have a multiuser system and a bunch of folks are entering data into a table at the same time every day you may eventually get the same response from Sys(2015). Less likely is the possibility that the user will reset the system clock. The standard procedure, I believe, is to create a system table (call it System.dbf) that contains key fields and the next available system key (NextID) for that table. Then write a procedure which is called with parameters indicating the appropriate keyname, which corresponds to a system ID field in another table. Whenever you add a record to your table, first call your procedure which locks the appropriate System.dbf record, increments the counter (System.NextID), unlocks the System record, and returns the value of the next free key. You save the returned value as the ID value in the table you are adding a record to. Sometimes a key value will get skipped but you never get duplicates. You can use system keys type N(10,0). If you need code to increment the counter, tell me your email address. Just make sure everything is locked before incrementing and unlocked afterwards.

Adam
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform