Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto increase number
Message
De
26/11/2003 10:00:49
 
 
À
25/11/2003 21:20:21
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00853567
Message ID:
00853687
Vues:
15
Hi John,

If you don't want holes or gaps in the numbering, then you may want to create your own autoincrementing function where you pass it the table and field name and it returns the next number. This way, you can call the function after the record has already been saved.

I use KEYVALS.DBF to store the table name, field name, increment and next value. The key values are retrieved using function GetKeyVal(tcTable, tcField).

For example, If I had PO.DBF, I'd put GetKeyVal('PO', 'POID') as the Default Value for my primary key then use GetKeyVal('PO', 'PO') after saving a PO record to create the actual PO number (REPLACE PO WITH GetKeyVal('PO', 'PO')). The PO.POID field would be my surrogate key and I wouldn't care if there were gaps in the numbers as the users wouldn't see this value. PO.PO would be the "PO number" that the users would see printed on the PO forms and on the screen and wouldn't have gaps unless it was intentionally deleted after being saved.

A quick look at the NewID() code led me to believe that it only supports generating autoincrementing numbers for a single field per table. I could be wrong but I need to focus on other features during my evaluation of the product.

Hope this helps,

Jason
---------
Single field, surrogate primary keys....because it's sexier!

Third normal form is more than just a good idea.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform