Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Primary key problem
Message
De
26/10/2001 11:19:45
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Primary key problem
Divers
Thread ID:
00573665
Message ID:
00573665
Vues:
50
Hi,

I've got a problem with primary keys. They look like "00001", "00002", etc. Anyways I have run into a situation where I have to reuse them. So for example, if the table contains five records, "00001", "00002", "00003", "00004", "00005" and the user deletes "00003" I wind up with "00001", "00002", "00004", "00005". I have to change it to "00001", "00002", "00003" (used to be 00004), "00004 (used to be 00005). I do this with the following code. The order is set to "tid" which is the Primary key.
scan rest
     replace tid with padl(str(val(tid)-1),5,"0")
endscan
I get a uniqueness of primary key error. I have set deleted on. If I do a pack it works, but I can't do that when the users are using it. Any ideas on how to solve the problem without making the primary key not primary? I am working with a treeview active x control and I am using this as a way to identify an item. The treeview source is a table. When the user deletes one, it is deleted from the table. Then I clear the treeview and add all the items all over again. Maybe there is a better way of doing this? It seemed like overkill when I did it, but can't think of any other way as I need to have the primary key matching the key for that item created by foxPro when the treeview is created.

Thanks!
Chris
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform