Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why not AutoIncrement PK inside a table?
Message
From
15/07/1999 22:26:57
 
 
To
15/07/1999 17:00:19
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00242011
Message ID:
00242130
Views:
22
>Right now I use a call to a stored procedure in the DBC
>to get the next sequential primary key (PK). The technique
>I am using is nearly the same as that used in the TasTrade
>app supplied with VFP - nothing fancy.
>
>Why is it that the auto incrementation is not contained
>inside the DBF header? The RECCOUNT() value is returned
>from and updated in the header. Seems like adding an
>additional column (like done with whether a column can
>accept .NULL. values) to ID the PK would be fairly easy
>to do. Also, an additional 4 bytes of space in the header
>can contain the 0 - 2,000,000,000+ values when using
>integer keys.
>
>Just curious why this has not been done before. I recall
>that trying to add a PK via ASP was not possible. At least
>not the way I tried it. Since the integer surrogate PK value
>would be totally encapsulated within the DBF header that
>problem would go away.
>
>Seems like this would be a nice feature to add to VFP 7...




Agree, Auto PK will save much time on handling add record.

But in real world, nothing is best!

In my company database, customer table has two or three ending for adding New Record!

For Real Customer, simple digit in character type (e.g. "618")
For Walk-in/Fax/Email Enquiry Customer, Start with "L" with 4 digit auto number.
(e.g. "L0123") because there is a group division on next Enquiry will be handled by which sales
For Self-Found Enquiry Customer, Start with "LT" with 3 digit auto number.
(e.g. "LT004") because the customer is found by sales him/herself and NOT follow the group division.


Now, if a Walk-in Enquiry Customer is added,
I need to do:

set order to cust_no
locate all left(cust_no,2)="LT"
Skip -1 && found the lastkey for "L" starting..

Lastkey = customer.cust_no
....

Newkey..

if an Enquiry Customer HAS made a New Orders after quotation,
Copy the cust_no to OldCustNO (i.e. OldCustNo = "L0123") and re-assign
the next REAL cust_NO (i.e. Cust_no = "0619")

Then, since there all use the cust_no as link for other tables,
such as Quote, I need to replace those "L0123" key with new key "0619" to
make it linked again...

Otherwise, ask sales to do this complex task through all tables will be
really Headache!!




In real world, most like you need to add a key In the middle after sort the key field in order...
really hard to force Auto PK as generate on Last Record
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform