Consultor Eletrônico



Kbase P146648: Query does not return correct recordset with CONTAINS against a field containing a WORD-INDEX
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/20/2009
Status: Unverified

SYMPTOM(s):

Query does not return correct recordset with CONTAINS against a field containing a WORD-INDEX

FOR EACH <table> WHERE <field> CONTAINS "abc"


"abc" is found
"1abc" is not found
"1abc1" is not found
"abc1" is not found

FACT(s) (Environment):

All Supported Operating Systems
Progress/OpenEdge Product Family

CAUSE:

CONTAINS without an Asterisk (*) wildcard will only return true if the whole word "abc" is found. Furthermore, CONTAINS only allows for a "*" at the end of the search string ("abc*"), meaning that only "abc" and "abc1" will return true.
The MATCHES operator on the other hand allows for a "*" both at the beginning and at the end of the search string. Therefore, "*abc*" will return true for all words that contain the search string in them ("abc", "1abc", "1abc1" and "abc1")

FIX:

Instead of CONTAINS, use the MATCHES operator along with the "*" wildcard before and after the search string