Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
When to assign unique key.
Message
De
04/11/1997 17:02:18
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00058229
Message ID:
00058238
Vues:
39
>I am working on a Customer Info form and I want to assign a unique customer number when a user chooses to add a new customer. If I do anything like a CALCULATE MAX() on existing customer numbers, the record pointer moves and a TABLEUPDATE() is automatically issued.
>
>Any ideas on the best way to do this?

MAX(), COUNT() and a few other commands move the record pointer. The best way to assign a unique key is with a procedure stored in the dbc that pulls the unique value from table that stores the next unique value for all of your tables that require a unique value. This may seem like a pain and overkill for the time being, but as your apps and tables grow, it becomes evident that this is the only way to go. So you have field that is not the primary key but needs a unique value anyway? Define it as candidate and use the same teqhnique. Tastrade contains a stored procedure and a table that does this. Another tip that has quickly become the 'right' way to do things: all primary keys should be surrogate. That is, the ser should never see them, and they should have no real world value.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform