-
1
- #1
Olaf Doschke
Programmer
The index expression causing the error as given in this thread title is
The concrete values of the record to be indexed are .T. and 48246, resulting in the index key value "048246". I feared I had a .NULL. creeping in, but that's not the case.
From the help topic about error 2199 the error happens, if an index expression may exceed the maximum length of 128 bytes, eg if you would index on a memo field. But then - AFAIR - the index creation itself would already error, which it doesn't. You can INDEX ON IIF(logicalfield,"0","1")+TRANSFORM(integerfield) TAG order_ix ASCENDING ADDITIVE.
I see TRANSFORM() does not pad to a static length, and the result value of a TRANSFORM may get as long as you like, if you'd pass in a string, for example. Indeed this index used for sorting data only works, as the value range of the integers is between 10000 and 99999, always the same length.
The error happens when executing in VFP9 and not in VFP7, so I'd say VFP9 has become stricter about what index expressions it allows. The error happens with the first record inserted. I can fix it using STR() instead of TRANSFORM(), though I have memories about indexes on STR() having a bug in VFP7.
Now the final though and tip about this: If you ever come across error 2199 check, whether your index expression may not strictly always have the same width. It doesn't matter if the width varies below 128 bytes, varying lengths alone are reason for VFP9 to error, as it seems.
And last not least: The rule of thumb is to pad an index expression, if needed, so it always has the same length below 128 bytes.
Bye, Olaf.
Code:
IIF(logicalfield,"0","1")+TRANSFORM(integerfield)
The concrete values of the record to be indexed are .T. and 48246, resulting in the index key value "048246". I feared I had a .NULL. creeping in, but that's not the case.
From the help topic about error 2199 the error happens, if an index expression may exceed the maximum length of 128 bytes, eg if you would index on a memo field. But then - AFAIR - the index creation itself would already error, which it doesn't. You can INDEX ON IIF(logicalfield,"0","1")+TRANSFORM(integerfield) TAG order_ix ASCENDING ADDITIVE.
I see TRANSFORM() does not pad to a static length, and the result value of a TRANSFORM may get as long as you like, if you'd pass in a string, for example. Indeed this index used for sorting data only works, as the value range of the integers is between 10000 and 99999, always the same length.
The error happens when executing in VFP9 and not in VFP7, so I'd say VFP9 has become stricter about what index expressions it allows. The error happens with the first record inserted. I can fix it using STR() instead of TRANSFORM(), though I have memories about indexes on STR() having a bug in VFP7.
Now the final though and tip about this: If you ever come across error 2199 check, whether your index expression may not strictly always have the same width. It doesn't matter if the width varies below 128 bytes, varying lengths alone are reason for VFP9 to error, as it seems.
And last not least: The rule of thumb is to pad an index expression, if needed, so it always has the same length below 128 bytes.
Bye, Olaf.