In a table I have a character field with binary information (6 char) and a index for this field.
LOCATE finds the searched record, but SEEK returns always TRUE but stays in the first record.
The field is created as <char (binary)>.
What does your seek expression look like? The command INDEXSEEK(seekstring) does what you are describing. It is a special variation of the SEEK command and SEEK() function where to tell it whether to move to the found record or not.
SEEK and SEEK() either move the record pointer to the matching record or if not found then to EOF(), end of file.
INDEXSEEK() has a second argument which by default is .F. so that it never moves the record pointer. If .T. then the record pointer moves only if a match is found.
If you're not using INDEXSEEK(), have you tried deleting the index or tag, then recreating it? If the SEEK works afterwards then maybe the index was corrupted.
Sorry, also INDEXSEEK does not work.
My SEEK expression is
=SEEK(cTxt, "Personal", "KartNo_IDX"
cTxt contains (in Hex) 0x00, 0x00, 0x00, 0x03, 0x05, 0x08 and this value exists in table "personal".
If I use the expression:
LOCATE FOR KartNo == cTxt
then everything works fine.
As I understand it you are getting a match on the =SEEK(cTxt, "Personal", "KartNo_IDX" and it happens to be the first record in the table - this was not what you expected, since the Locate returns the first match as a totally different record (presumably the one you want). I noticed in looking at your code that you are using == with your locate so that it exactly matches, so my suggestion is try this:
SET EXACT ON
=SEEK(cTxt, "Personal", "KartNo_IDX"
...assuming that your index is correct for this seek this will cause the SEEK to look for an exact match similar to what you are using in locate statement.
I allways use SET EXACT ON.
And my index is not corrupted (only 3 entries, and rebuilded a few times)
But with SEEK I allways get TRUE returned (alltrough when I searche a record, which is not within the table) and the pointer stays allways on the first record.
I tried to create your problem (I think some people here already tried also). The result is, both SEEK and INDEXSEEK works correctly. But in your case it doesn't work.
Since you said it's only 3 entries, why don't you list what is the field value inside your table and what is the code (where the problem is) to search. Maybe we can figure out what is wrong
Did you realy put binary values into the char field?
Of course all my SEEK operations works correctly: I have only problems with them, wich contains binary values.
So may I ask again: did you try it with binary values, e.g.
cTxt = CHR(0) + CHR(0) + CHR(0) + CHR(3) + CHR(5) + CHR(8)
This is what I did.
- Create a table with character binary field (6 char)
- index on the field
- cTxt0 = CHR(0)+CHR(0)+CHR(0)+CHR(3)+CHR(5)+CHR(8)
- cTxt1 = CHR(1)+CHR(0)+CHR(0)+CHR(3)+CHR(5)+CHR(8)
- insert into "table" values (cTxt0)
- insert into "table" values (cTxt1)
- ?seek(cTxt0), recno() && result: .T. , 1
- ?seek(cTxt1), recno() && result: .T. , 2
I'am going to cry. I did the same as you (copy & past). Same result as before: I get allways TRUE as seek-result but the record-pointer stays in first position.
Should I reinstall vfp? But why everything works correctly and only in this special case the "bug" becomes alive?
When you said you rebuilt the index, did you REINDEX or did you actually delete the tags, and re-create the index? It is certainly possible that simply REINDEXing isn't enough to wipe out the index corruption.
With the table open you can type DISPLAY STATUS to view table and the details of its index. Is it correct?
Alternatively, with so few records, you could make a new table and new index and see if you still have the problem.
Yes, I made both of them: REINDEX and delete the tags. And, of course, I created a new Table with only this single field. In all cases the same result.
I use codepage 1254 (turkish). Can this be the problem? Otherwise CHAR (binary) should made no translation.
Uff! I found a small light in the darkness. If I create a table with codepage 1252, than the seek operation runs as desired.
Whats now? I have to work with codepage 1254 ...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.