Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!hacgate!ashtate!dbase!awd From: awd@dbase.UUCP (Alastair Dallas) Newsgroups: comp.databases Subject: Re: Clipper/dBase Seek Question Summary: INDEX ON LTRIM(..) is a bad idea Message-ID: <202@dbase.UUCP> Date: 23 Aug 89 17:08:43 GMT References: <238@fltk.UUCP> <20900014@silver> Organization: Ashton Tate Devlopment Center Glendale, Calif. Lines: 36 In article <20900014@silver>, blank@silver.bacs.indiana.edu writes: > > Also, make sure that the number of spaces in front of the number are > the same. In fact, all of these types of searches, I add a ltrim to > avoid the problem: > > index on ltrim(str(invnum))+"*"+ltrim(str(seqnum)) > seek ltrim(str(invnum))+"*" > > -doug INDEX ON LTRIM(..) is a bad idea. It is very important that index keys be fixed length, and TRIM() or LTRIM() do not support this: .INDEX ON LTRIM(STR(N)) TO Foo .LIST STR(N), LTRIM(STR(N)), LEN(LTRIM(STR(N))) 1 13 13 2 2 12345 12345 5 3 233 233 3 4 166 166 3 5 32 32 2 6 0 0 1 Indexes must have fixed length keys. Quoting the dBASE IV manual (p2-150): "dBASE IV does not prohibit you from creating an index with a variable-length key, but the index may not be reliable." /alastair/ N STR(N) Key Length 13 "13" 2 123456 "123456" 6 0