Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the next number via Stored Procedures
Message
 
À
24/05/2005 00:55:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01016957
Message ID:
01016993
Vues:
15
What Hilmar suggested already is the way to do this. Simplistic example: Say you have 2 tables, one is tblTrans and the other is tblKeys. tblKeys has two fields, an integer field for the primary keys and a table name field so it can work for multiple tables. Then you create a Stored Procedure, let's call it GetPrimaryKey, that will use tblKeys, look up the table name based on a parameter sent in and will read the transaction number there, increment it by one (so the next call gets the next number), and return the transaction number it looked up. It will also add a record to the tblKeys table if it doesn't find a matching record when doing it's seek. Then in tblTrans, for your transno field (or whatever you called your primary key field that holds the unique transaction numbers for the records) you put the following in the default value when you are in the table designer: GetPrimaryKey("tblTrans"). Now you have all the parts for creating unique primary keys for tables, whether they are transaction numbers for tblTrans or primary keys for some other table you have. This is a better and much safer approach than using Auto Incrementing fields.

>Hi hilmar,
>
>The number that will be returned from a stored procedure will be used as a transaction number in a different table.
>
>any idea?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform