Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Keylist for Primary Key Stored Proceedure
Message
From
16/12/1998 18:49:47
 
 
To
16/12/1998 18:44:44
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00168325
Message ID:
00168327
Views:
35
>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
Map
View

Click here to load this message in the networking platform