Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uniqueness of index PRIMARY is violated
Message
From
14/10/1998 15:05:11
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00144393
Message ID:
00146806
Views:
38
>...and I rebuilt my project.
>
>Here what happened...
>...Same stuff
>...it made no difference.

OK, now when the usual suspects are out of town, let's see who's in.

>My primary index, "PrimaryKey", is defined as:
>LEFT(ALLTRIM(filename),RAT("\",ALLTRIM(filename)))+RIGHT(ALLTRIM(filename),11)+SUBSTR(ALLTRIM(filename),RAT("\",ALLTRIM(filename))+1,1)

Now you can't actually be sure of the actual length of your key expression once it gets evaluated - and I guess VFP measures its length from the first record. The only thing which has variable length here is the month - if your first record wasn't in February (8 chars), but in May instead (3 chars), the length of your key is taken 5 bytes shorter than it needs. The quick'n'dirty solution for you would be to have

PADR(LEFT(ALLTRIM(filename),RAT("\",ALLTRIM(filename)))+RIGHT(ALLTRIM(filename),11)+SUBSTR(ALLTRIM(filename),RAT("\",ALLTRIM(filename))+1,1), 160)

as your key, though I was thinking there should be another way, like

stuff(filename, rat("\",filename)+1,1,"") - subs(filename, rat("\",filename)+1,1)

Note the use of the minus operator - it will move the R or C character before any trailing blanks, so the trailing blanks are "removed" by compactness of the index engine itself, and not by string manipulation in the key expression. This key has length of filename+1, is fixed length, and should work. Also should be slightly quicker, I hope.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform