Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Autogenerate Primary Keys Problem
Message
 
To
11/03/1999 21:52:16
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00196629
Message ID:
00196652
Views:
25
Jason,
First, are the Primary Key fields in your application all changed to date type? Also their indexes?

Second, In the code below, did you change the code in your if/else statement so it used an empty date { } instead of a numeric 0?

Step through the code and find out exactly where it bombs. That will give you a hint about which field or variable you missed converting from numeric to date.

HTH
Barbara

>Hi everyone -
>
>I have built all my tables in my application, but as fate would have it, I have decided to change my primary keys from being all numeric, to being all character (date type). I thought this would be a snap, but when I did what I felt was necessary to accomplish this, I received an error message that says "operator/operand type mismatch":
>
>Currently, I have the application set as follows (which works like I charm). My stored proceedure is as follows>
>
>FUNCTION GetKey
>
>PARAMETER lcKeyName
>
>LOCAL lnKeyNum
>
>IF NOT USED("keylist")
> USE keylist IN 0
>ENDIF
>IF SEEK(ALLTRIM(lcKeyName),"keylist","keyname")
> REPLACE keynum WITH keynum+1 IN "keylist"
> lnKeyNum = keylist.keynum
>ELSE
> INSERT INTO KEYLIST(KEYNAME,KEYNUM)VALUES(lcKeyName,0)
> lnKeyNum = 0
>ENDIF
>USE IN keylist
>RETURN lnKeyNum
>____________________________________________________
>
>My keylist table is set up as follows:
>
>table is called "keylist"
>field: keyname character data type regular index
>field: keynum numeric data type no index
>
>
>In the default box of my tables I have the code (using my category talbe as an example):
>
>getkey("category")
>
>** the primary key is labeled ncategoryid in this example
>_______________________________________________________
>
>OK, to this point, I am fine. But, I want to change from a numeric data type to a character data type.
>
>I did the following to change to a character data type, but failed:
>
>1. I changed the "keynum" field of my keylist table to character data type.
>
>2. I changed the nameing convention used in my fields. Ex: ncategoryid to ccategoryid
>
>3. I went into my getkey program and everywhere there was "lnKeyNum, I changed it to lcKeyNum
>
>
>
>After i did that I received an error code when I tried to append a record.
>
>If anyone has some ideas, advice, etc. I would sure appreciate it.
>
>Thank you very much
>
>Jason
Barbara Paltiel, Paltiel Inc.
Previous
Reply
Map
View

Click here to load this message in the networking platform