Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Codebook Tip - Integer Primary Keys
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Titre:
Codebook Tip - Integer Primary Keys
Divers
Thread ID:
00047514
Message ID:
00047514
Vues:
67
All,

We have made a change to our Codebook for Mere Mortals framework that will be included in the next release (Version 2.07 available in the next few weeks) that is also useful for all Codebook developers.

By default, Codebook generates character-type primary keys for tables. But with a slight change you can also generate integer primary keys. If you are unfamiliar with the beauty of integer keys (speed and reduced file size), check out Mac Rubel's article "Real Programmers Use Integers" in the May '97 issue of FoxPro Advisor.

Here's a list of the necessary changes:

1. In your database container, modify the stored procedure NewID(). At the bottom of the procedure, change the following code:

Change...
RETURN TRIM(luID)

To...
IF id.Type = 'C'
RETURN TRIM(luID)
ELSE
RETURN luID
ENDIF

2. Edit ID.dbf properties and change the size of the "Value" field from Char 6 to Char 11.

3. When you add a record for the table to ID.dbf, specify the IncrementProcedure as: IncrementBase10(LEFT(id.value,id.maxlength)) and specify the Type as "I".

4. When you want a table to have an integer primary key, just specify the "iID" primary key field as Integer.

If you make this change to the Generic.dbc (as we have done) all newly generated applications will inherit the ability to generate both character and integer primary keys.

Regards,
Kevin McNeish
Oak Leaf Enterprises Solution Design, Inc.
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform