When you use wildcard characters with the LIKE operator in IBM® Content Manager queries, the queries on the attributes of character types behave differently than the queries on the attributes of variable character types. The difference in behavior occurs because the length of the attributes of character types are fixed. To make the queries more effective, you can use the multiple wildcard characters to represent all trailing characters after the search term.
For example, if in the Journal component type view, the PublisherName attribute is defined to be a variable character type and one of the components has the value IBM in this attribute, then the following query returns the result that contains this attribute value because the PublisherName attribute is of variable character type. If the value IBM is stored in this attribute, the length of the attribute is 3 and the following query returns the results that contain the string IBM.
/Journal [@PublisherName LIKE "IB_"]
However, if in the Journal_Editor component type , the Affiliation attribute is defined to be a character type and one of the components has the same value IBM in this attribute, then the following similar query does not return the result that contains the value.
//Journal_Editor [@Affiliation LIKE "IB_"]
When the value IBM is stored in the attribute of fixed character type, the three characters of the word IBM are followed by 61 blank spaces (64 - 3 = 61) because the Affiliation attribute contains 64 characters. These blank spaces are padding characters, where the exact type of character used depends on the database settings. Because the wildcard underscore character (_) that is used with the LIKE operator matches any single character, only values starting with two letters I and B, followed by any third letter are returned in the example query on the Affiliation attribute in the previous section. Because all values in the Affiliation attribute contain 64 characters (not 3 characters), the following query does not return any results:
//Journal_Editor [@Affiliation LIKE "IB_"]
To make the queries less error-prone because of this difference, you can use the multi-character wildcard to represent all trailing characters after the search term. To find all results with attribute values that start with a specific pattern for attributes of fixed character length, you can use the multiple wildcard characters % as follows:
//Journal_Editor [@Affiliation LIKE "IB%"]
//Journal_Editor [@Affiliation = "IBM"]
