Previous Topic Next topic Print topic


LIKE Operator

Restriction: This topic applies to Windows environments only.

The XDB Server supports the DB2 implementation of the LIKE string pattern matching operator. The syntax for a LIKE pattern match predicate appears below:

expression [NOT] LIKE
{special-register | host-variable | string-constant}
[ESCAPE {host-variable | string-constant}]

where:

expression The expression parameter string value is compared to the pattern string, and can be any valid expression-- as long as the result of the expression is a string. The expression can consist of a single table column name or contain a column name as part of the expression.
special-register Indicates that the string is stored in the named special register.
host-variable Indicates that the string is in the named host variable. The host variable must be already be defined in accordance with the rules for declaring string host variables.
string-constant Includes the pattern as a string constant within the predicate.

In each case, the pattern string value represented by either the special-register, host-variable or string-constant parameter is matched against the string value of expression -- for each table record specified by the query.

Pattern Strings

The host-variable and string-constant parameters can utilize two special reserved characters (wild card characters) -- the percent sign ( % ) and the underscore ( _ ) to perform pattern match searches against the string values in expression. The percent sign character matches any string (of any length), while the underscore character matches any single string character.

ESCAPE

The optional ESCAPE clause designates a special escape character, which if placed immediately before a percent ( % ) or underline ( _ ) character causes that percent or underline character to be literally interpreted as part of the pattern string. The escape character value can be specified with either a string-constant (enclosed in quotes) or host-variable (must not be a structure).

Previous Topic Next topic Print topic