Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique ID Violated With Add/Delete
Message
 
À
15/06/1998 12:45:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00108257
Message ID:
00108332
Vues:
28
You may want to go to an outside control table for the next sequential number to be processed for the new record... I have a system that does just that and in the database container for the primary/candidate field I have a default value to call a stored procedure...

I have expanded on the more simplified approach of just adding one to the value. The stored procedure basically covers the following steps...

1. Parameter of what table the record is being added to

2. Opens a SYSKEYS table which has
Table Name to add record
Tag identifying the primary key (single field, not concatinated field list)
Next ID available

3. Locate the record for the table needing new record
If not found, add and default key to 1

4. Uses the table about to receive the new record AGAIN with alias BOGUS1 (example)

5. Set order in "BOGUS1" (example) and go bottom

6. If the current key in the SYSKEYS table is greater than the last record on file, just add one and continue. If the current key in the SYSKEYS is less, force the SYSKEYS with the current "BOGUS1" key value then add one for the new key.

By using a stored procedure and the "default value" of the primary field, this will always be called when adding records and I have never had a duplication problem yet...

Hope this approach works for you.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform