Escape characters
Some characters in content integration server queries have special meanings.
For example, to search for the literal value View*Star, you must escape the asterisk in the middle of the string. Use a backslash to escape such characters:
- Property search
CompanyName LIKE 'View\*Sta?'
- Full-text search
PHRASE = 'Did you ask why\?'
- Asterisk (*)
- Question mark (?)
- Backslash (\)
- Single quotation mark (')
Query criteria string | Results | Explanation |
---|---|---|
String LIKE * |
String, Strong, Stronger, Strange, Stranger, Str*ng, Str?ng, Str'ng,
Str_nger, Str?*r, Str*n*, Str\anger, Str\onger, Str\?nger, Str\ange, Str\?nger, Str??ng, Str??nge,
Str??ng*, Str?nger, Str\\?nger, Str\?\?ng, Str\?\?nger, Tom's Cabin |
All results are returned. |
String LIKE ‘Str?n*’ |
String, Strong, Stronger, Strange, Stranger, Str*ng, Str?ng, Str'ng,
Str_nger |
Replace single character for ? , and multiple characters for
* at the end of the word. |
String LIKE ‘Str?ng’ |
String, Strong, Str*ng, Str?ng, Str'ng |
Single character wildcard search. |
String LIKE ‘Str?*r’ |
Stronger, Stranger, Str?*r, Str_nger |
Results strong and strange would not be returned because of the r at the end of the query string. |
String LIKE ‘Str\*n*’ |
Str*ng, Str*nger, Str*n* |
The character combination \* indicates that the first
asterisk is literal and not a wildcard character. |
String = ‘Str*ng’ |
Str*ng |
Asterisk and question mark characters are meaningful only when the operator is LIKE. |
String LIKE ‘Str\\?nger’ |
Str\anger, Str\onger, Str\?nger |
The backslash character in the query string is a literal, while the
? character is a single replacement wildcard character. |
String LIKE ‘Str\\?n*’ |
Str\ange, Str\anger, Str\onger, Str\?n* |
The backslash character is literal because it is escaped in the query string. |
String LIKE ‘Str\?\?ng*’ |
Str??ng, Str??nge, Str??ng* |
The values Str\?\?ng and Str\?\?nger are not
found because the ? characters are both escaped with backslashes in the query
string. |
String LIKE ‘Tom’s Cabin’ |
InvalidQueryException |
Malformed query. The single quotation mark character within the word Tom's must be escaped in the query string. |
String LIKE ‘Tom\’s Cabin’ |
Tom’s Cabin |
The string Tom\’s Cabin is not found because the backslash is
used as an escape character in the query string. To find the literal string Tom\’s
Cabin , both the backslash and the single quotation mark must be escaped in the query
string: Tom\\\'s Cabin . |
The single quotation marks and backslash characters must be escaped wherever
they are used as literals in a content integration server query because these characters have a
special meaning to IBM Content Integrator. If these characters are not escaped, an error might occur
or the query might produce undesired results. For example, if you query for the string Tom's
Cabin
and you do not escape the single quotation mark, the query expression parser returns
an exception and the query is not run. To search for Tom's Cabin, you would enter:
String = 'Tom\'s Cabin'
The string is converted by the
connector into a form that is acceptable by the repository to produce results for the string Tom's
Cabin. This might convert into Tom''s Cabin
or Tom's Cabin
depending on which repositories are searched. Client applications do not need to accommodate
different repositories' accepted inputs because each corresponding connector handles the
differences. Client applications can search seamless between the various repositories without regard
to the repositories' special character or mechanism of escaping special characters.
Each repository has a repository profile that lists invalid character combinations. Invalid character combinations might be listed if the repository does not support escaping wildcard characters, if there are characters that are special to the repository that cannot be escaped, or if there are any other characters that are illegal to the repository. Never use these character combinations in a query on a repository with such restrictions.