>Any suggestions about the index expression NOT matching the field situation?
>
Rather than
==, you could try using $ (substring find) but you'll need to take some care in constructing queries if you have a complex expression, since Rushmore requires an exat match on the index expression for it to be used. You could also check using
=, so that if the field were the first part of a complex expression, it'd match.
You might want to modify the code to find all the pssoble matches if an exact match isn't the only thing considered; there could be >1 index tag that matches up with a less restrictive match criterion. You might also want to exclude filtered indexes (index containing a FOR clause) from consideration. You can check for a filter on an index using SYS(2021).
>
>>>How do I check if a field has an index?
>>>
>>>I would like to know if my REPNUM field has an index but I can't find a way of doing this.
>>>
>>>I have been trying TAG(), TAGNO(), TAGCOUNT(), CDX() and other functions but no answer yet.
>>>
>>
>>The easiest way would be to spin through the atgs and examine the index expression using SYS(14):
>>
>>
USE <i>JRandomTable</i>
>>LOCAL nCtr, nTagCount
>>nTagCount = TAGCOUNT()
>>FOR nCtr = 1 TO nTagCount
>> IF UPPER(SYS(14,nCtr)) == 'REPNUM'
>> EXIT
>> ENDIF
>>ENDFOR
>>* If nCtr <= nTagCount, there's a tag, and it's number is nCtr
>>* You can now get the name of the Tag with TAG(nCtr)
>>* This won't work unless the index expression matches the field with
>>* no functions or extended expressions; if this were a character
>>* field and a tag with that field was used as a part of a concatenated
>>* key, or you used the UPPER() function, it won't match
>>
>>>Thank you in advance.