Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indexes not working.

Status
Not open for further replies.

Webrookie

Programmer
May 18, 2000
112
US
I need some help before i throw my monitor out the window.

Believe it or not I've been using Foxpro for 3 years, everything from 2.5 to ver 6 currently. With that aside,

I have a table. I have two indexes in a cdx. one index works, one doesn't.

why? why when i seek in one does it work, and not in the other?

both fields are character, one is 4 in length, and the other 15. both contain strings of numbers.

why?
 
also, the one that doesn't work...WILL work if I don't alltrim the value i'm seeking, even though i index on an alltrimed field.
 
Can you post the code of the one that doesn't work? How do you seek? Do you use ALLTRIM() or "=="? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
index created via

index on alltrim(fieldname) tag fieldname

use (tablename)
set order to (Tagname)
seek "value"

 
it seems like it's just this table.

my other tables for other projects all seem to respond correctly.

awesome that narrows it down!

:(

i'm gonna reboot my pc nine times maybe that will fix it.
 
WebRookie

This does not work:
SET EXACT ON
SET NEAR off
CREATE CURSOR mycursor (name c(20))
INDEX ON ALLTRIM(name) TAG name
INSERT INTO myCursor (name) VALUES ("Mike")
INSERT INTO myCursor (name) VALUES ("Paul")
INSERT INTO myCursor (name) VALUES ("Frank")
INSERT INTO myCursor (name) VALUES ("Giancarlo")
SET ORDER TO tag name
IF SEEK("GIANCARLO")
MESSAGEBOX("Found")
ELSE
MESSAGEBOX("Not found!")
ENDIF

Is it a case of uppercase? Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
well, they're numbers that i'm seeking, so case shouldn't matter
 
WebRookie

You may have a corrupt index...delete the index and re-index. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
that didn't work. and i tried reindexing.

thanks for your help anyway.

i'm just gonna create the table from scratch and start over.
 
WebRookie,
It's never a good idea to use a potentially variable length index key like "alltrim(fieldname)". Because keys must always be a fixed length, then it's better to use:
Code:
index on PADR(alltrim(fieldname), LEN(fieldname)) tag fieldname
In fact there was (at least) one version of FP that actually created the length of the key based on the first value it found in the table. So if the field was C(10) and the first record just happended to have "X " in it, then an index tag defined as alltrim(fieldname), gave an index length of 1 (one!) - obviously this was good for the keeping the index file size small, but it was terrible for searching for ten character names!

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top