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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing duplicate keys in cdx

Status
Not open for further replies.

doton

Programmer
Feb 27, 2019
14
0
0
MX
I need to index a table whose index key is 200 characters long, and to allow duplicates.
What commands should I use to create the table and its cdx file?

Dave Norman
 
What you describe, is the default behavior for the Index command.

[pre]Use yourtable exclusive
Index on yourexpression tag yourtag[/pre]
 
I use the following code:

OPEN DATABASE c:\foxahorro\ahorro.DBC
Use ahorro!peps2019 exclusive
Index on nombre tag yourtag
SET INDEX TO c:\foxahorro\peps2019 TAG yourtag
REINDEX
BROWSE

There are only 4 récords in the file at present, the field nombre has values of d, b, a and d

the browse command shows them in the same order, ie not indexed
 
Hi Doton,

With Index on ... you create the index, but you do not yet activate it.
Use “set order to tag yourtag” instead of “ set index to...”

Gerrit
 
Yes, because that's not what you do.

[tt]INDEX ON nombre TAG yourtag[/tt] does create a tag "yourtag" inside peps2019.cdx (or however the table is named) and not a peps2019.idx file.
And you don't activate that index with SET INDEX To some file, that is the command to use with IDX indexes.

Once you created an index tag in the CDX you either [tt]USE ahorro!peps201 ORDER TAG yourtag[/tt] or you [tt]SET ORDER TO TAG yourtag[/tt] after you opened and selected the DBF or to switch between index tags.

You shouldn't use IDX index files for normal use, as these indexes only update together with DBF/FPT file changes when they are actively set, CDX files get updated even if you don't SET ORDER.

You may have a problem with 200 char field, as index TAGS are limited to 240 bytes, which in any collation but MACHINE is only 120 double-byte characters. But indexing in MACHINE collation is recommended to make the most use of indexes for Rushmore anyway, especially as that's the collation to use for any non-character data type anyway.

Bye, Olaf.



Olaf Doschke Software Engineering
 
In addition to what the other have written, remove that Reindex command!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top