>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
My code assumes an index on keyname called idxKName in this line:
>IF SEEK(ALLTRIM(lcKeyName),"keylist","idxkname")
I'm guessing that's what's giving you the error.
-Michelle
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only