Information générale
Titre:
Keylist for Primary Key Stored Proceedure
Hello Developers
I am stuck on a step that I need to learn to auto-generate primary keys for multiple tables. A developer this morning was kind enough to help me with the stored procedure, which is the following:
FUNCTION GetKey
PARAMETER lcKeyName
LOCAL lnKeyNum
IF NOT USED("keylist")
USE keylist IN 0
ENDIF
IF SEEK(ALLTRIM(lcKeyName),"keylist","idxkname")
REPLACE keynum WITH keynum+1 IN "keylist"
lnKeyNum = keylist.keynum
ELSE
lnKeyNum = 0
ENDIF
USE IN keylist
RETURN lnKeyNum
_______________
The code is fine, however, I am running into trouble with the associated keylist table [i believe... ]. I created a table called keylist with two fields: KeyName and KeyNum
In the keyname field I have added all 6 of my tables as a seperate record, with a keynum of 1
In each of my 6 tables, I have placed the phrase >
getkey('tablename') in the default value box.
When I go to my tables to test it out, I can't even append a record. I get an error message that says 'index tax not found' .. proceedure canceled.
What am I doing wrong?
I would appreciate any help. Thank you
jason
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement