LONG VARCHAR columns in queries

In WHERE clauses of the SELECT statement, LONG VARCHAR columns can only be used in IS NULL and IS NOT NULL expressions, in addition to the BIT_LENGTH, CHAR_LENGTH, CHAR_LENGTH64, CHARINDEX, LOCATE, OCTET_LENGTH, PATINDEX, SUBSTRING64, and SUBSTRING functions.

You can use the LIKE predicate to search for a pattern on a LONG VARCHAR column. All patterns of 126 characters or less are supported. Patterns of length greater than 254 characters are not supported. Some patterns of length between 127 and 254 characters are supported, depending on the contents of the pattern.

LONG VARCHAR columns cannot be used in the SELECT statement clauses ORDER BY, GROUP BY, and HAVING or with the DISTINCT keyword (SELECT DISTINCT and COUNT DISTINCT).

See “Function support of LONG VARCHAR data type” for more information on LONG VARCHAR data and functions.

WD index support

The following enhancements support the WORD (WD) index on LONG VARCHAR (CLOB) columns:

Note that Chinese text or documents in a binary format still require ETL pre-processing to locate and transform the words into a form that can be parsed by the WD index.

CONTAINS predicate support

Using the CONTAINS predicate, you can now search for string constants of maximum length 255 characters on a LONG VARCHAR (CLOB) column, in addition to CHAR and VARCHAR columns.

Note that the CONTAINS predicate is not supported on LONG BINARY (BLOB) columns. If you attempt to search for a string in a LONG BINARY column using a CONTAINS predicate, an error is returned.

For more information on CONTAINS string searches, see “CONTAINS conditions” in Chapter 2, “SQL Language Elements” of the Reference: Building Blocks, Tables, and Procedures.