Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Auto increase number
Message
From
26/11/2003 10:00:49
 
 
To
25/11/2003 21:20:21
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00853567
Message ID:
00853687
Views:
14
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform