[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1338
  • Last Modified:

error building key for index

Visual FoxPro 09.00.0000.5815 for Windows

I have a table with several indexes that are set as unique.
These indexes have been in place for several years.
Just recently when issuing an append blank I get the error  <error building key for index  workdate.
The index definition is: workcode + dtoc(invodate) - workcode is C(17) and invodate is D.
The is a flock() placed on the file just prior to the append blank.
If I open the same table in a vfp session I can append blank all day.
Not sure where to go next with this issue.
Need to resolve a.s.a.p..
I have done several selects to weed out any invalid dates etc.
Tried the same code on different workstations.
But still the problem remains.

0
kpi_it
Asked:
kpi_it
  • 2
2 Solutions
 
jrbbldrCommented:
"in a vfp session I can append blank all day"

So you are telling us that within the compiled application you are getting the error message but when in the VFP development mode, you get NO error?

Have you tried running the application's forms, prg's, etc. from within the development mode utilizing the TRACE window so that at the precise point in the code where the error is generated, you can examine the variety of other, possibly associated, settings?

On a different note - you might want to consider changing the DTOC() portion of the index expression to DTOS().   They both would work, but DTOS() orders things (as seen visually) in a more logical manner than does DTOC()

Good Luck

0
 
pcelbaCommented:
Hmm, haven't seen this error yet... and the help description does not fit to your data.

You should check the SET CENTURY setting in your app as the first step.

Then I would recommend to change the key expression to:

PADR(workcode + dtoc(invodate), 27)
or even to
PADR(workcode + dtoc(invodate,1), 25)
Depends how are you using this index.  The PADR() should not be necessary in the last expression but who knows what is happening...

The dtoc() function does not return results suitable for indexing - it depends on SET CENTURY and SET DATE settings at least. SET CENTURY could be the reason of above error but I am not sure.

DTOC(invodate,1) returns 8 characters in given format which is not dependent on the environment settings.

Of course, if you are using above index for records searching then changing the key expression would mean to change your code and you have to decide if this change is suitable now.

Another question would be why UNIQUE indexes? If you mean the classic old unique index created by
INDEX ON workcode + dtoc(invodate) TAG workdate UNIQUE
then it has limited usage in FoxPro application but you probably know it.

0
 
kpi_itAuthor Commented:
the switching of dtoc() to dtos() did the trick.
Had thought of it earlier, but didn't think that something that has worked for years.
And has worked the past two years with VFP 9 just would suddenly just stop is weird.
0
 
jrbbldrCommented:
I am glad that the DTOS() did the trick for you.

Just make sure that if you are doing any SEEK's within your application that the expression that you use, also makes use of the DTOS() instead of DTOC() so that your SEEK can actually find what you want.

Good Luck

0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now