Free Trial | Purchase | Products | Downloads | Support
Indexing on Numerical Fields
A common problem in working with indexes is that people attempt to index on numeric fields types without taking the extra step of using the STR( <field>, <width>) function to pad the data. FoxPro supports calling STR( <field> ) without specifying a width, however Apollo requires a width to be specified.
The following works fine under
The equivalent under Apollo is:
The value of NUMERICFLD could be different sizes. So, if we assume both STRINGFLD fields are CHAR(10), we would get the following:
Using the above index expression, the index values would equate to (# is space):
These index results are different sizes - the second is 2 bytes shorter which results in bad index values leading to incorrect search results. However if you use the STR( <field>, <width>) as STR( NUMERICFLD, 10), you would get the expected result:
Both index results are the same size. The same technique applies to the PADL(), PADR(), PADC() padding functions: you would need to make the numeric expression a consistent string width. You need to apply the same logic to your search and scope values and make the values being searched conform to your index expression.
Do not index numeric fields without STR(), PADL() or
Index numeric fields as follows:
You can also combine numeric fields with non-numeric fields as
Using Specific Components
Knowledge Base Articles
© Copyright 1999-2022 ApolloDB. All rights reserved.