Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>>How are developers handling the problem where a primary key and data record is added to a table. The user decides to start the record over so they delete the record. When they start to add the record again with the same key, they will get a duplicate key message because the key, although deleted, is still in the index, until I pack the file. One idea would be to change the key when I delete the record. Is there a better approach anyone is using.
>
>Don't recirculate primary keys - once you've assigned a primary key, it's gone and no longer usable, even if you never actually post it through. In most cases, I'd use a surrogate key - an artificial key used only for relation handling - and discard it even if it nver posted to the table.
That is how we handle it. NewKey(), a stored procedure, supplies the default value, looks up the last key in KeyList.dbf, verifies it and increments, never recirculates.
Précédent
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