Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incorrect RECNO() being stored
Message
 
À
25/06/1998 12:23:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00111582
Message ID:
00111631
Vues:
19
I think Ed's solution is the best more or less bulletproof one. I implement something similar in my apps. I have a table called SETUP with the names of every table, and the next id to be issued in it....In the default value of each primary key, I have:

getid('employees')

(where employees is the name of the table and in the stored procedures):

PROCEDURE GETID
PARAMETERS gettable
** Gets the next id for each table
LOCAL lcoldalias, lnreturn
lnreturn=0 && to hold the new id
lcoldalias=alias() && so we can return to the originally selected table
USE setup ORDER tablename in 0 SHARED && open the setup table
SELECT setup
SEEK gettable && Look for the name of the table to be added to
IF FOUND()
LOCK() && Lock the record - set reprocess should allow others to get it &&after this is done
lnreturn=nextid && Grab the id
replace nextid with nextid+1 && Increment the id by one
UNLOCK && Unlock the record
ENDIF
select setup
use
select (lcoldalias)
RETURN lnreturn && Return the id from the setup table

It seems to me that anyone tryibng to get unique values has to have some variation of this scheme. To me it seems pretty simple - all table share this same method for key generation. The main thing it does it prevent two people from ever getting the same number. And that of course is the goal, whowever your variation of this idea gets you there.

Jerry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform