Consultor Eletrônico



Kbase P186307: How to find exact matches in a WORD INDEXED field?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/04/2011
Status: Unverified

GOAL:

How to find exact matches in a WORD INDEXED field?

GOAL:

How to use a WORD INDEX to find exact matches?

GOAL:

How to combine the CONTAINS operator and the INDEX function to find exact matches in a WORD INDEXED field?

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

The following code snippet uses the CONTAINS operator and the INDEX function to find exact matches for the expression " On Credit " in the WORD INDEXED Customer.Comments field:

FOR EACH customer NO-LOCK WHERE Comments CONTAINS "on credit" AND
INDEX( comments, " on credit ") > 0:
MESSAGE comments
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
Please note the result set returned by the above code snippet will not include records where the Customer.Comments field starts with "on credit " (no leading space) or ends with " on credit" (no trailing space) or end with " on credit." (a trailing period). To include such records, the code may be refined along the following lines:
FOR EACH customer NO-LOCK WHERE
Comments CONTAINS "on credit" AND
(INDEX( comments, " on credit ") >0 OR
Comments BEGINS "on credit " OR
SUBSTRING(comments, LENGTH(comments) - 9) = " on credit" OR
SUBSTRING(comments, LENGTH(comments) - 10) = " on credit."
).
MESSAGE comments
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.