Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with primary key.
Message
De
01/11/2002 12:57:45
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00717718
Message ID:
00717921
Vues:
16
I had the same problem and there are a few different solutions.

Solution 1. Your primary key needs to have a filter placed on it. !deleted() (yuck)

Solution 2. Before you determine the highest number in the table SET DELETED OFF add the new record and SET DELETED ON when done (poor design!!!!)

Solution 3. Create a stored procedure that will automatically create a unique key (AutoIncrement). There was a posting on here about storing the key in a table.


e.g. Create a table with Table C(30), nKey I

In the Default portion of the database container e.g. Names.LastName DEFAULT = GetKey("Names")

The stored procedure will:
1. lock the new table
2. find the Names record
3. increment the nKey field (nOldKey = nKey) (nKey = nKey + 1)
4. unlock the file
5. return nOldKey

This is a little complicate to explain but, the MAX(Names.ID) will always be 1 less than the ID stored in the new table.


Solution 3 is the best solution!!!!
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform