String Functions

String functions perform conversion, extraction, or manipulation operations on strings, or return information about strings.

When working in a multibyte character set, check carefully whether the function being used returns information concerning characters or bytes.

Most of the string functions accept binary data (hexadecimal strings) in the string-expr parameter, but some of the functions, such as LCASE, UCASE, LOWER, and LTRIM, expect the string expression to be a character string.

Unless you supply a constant LENGTH argument to a function that produces a LONG VARCHAR result (such as SPACE or REPEAT), the default length is the maximum allowed.

SAP Sybase IQ queries containing one or more of these functions might return one of the following errors:

ASA Error -1009080: Key doesn't fit on a single database page: 65560(4, 1)
ASA Error -1009119: Record size too large for database page size
For example:
SELECT COUNT(*) FROM test1 a WHERE (a.col1 + SPACE(4-LENGTH(a.col1)) + a.col2 + space(2- LENGTH(a.col2))) IN (SELECT (b.col3) FROM test1 b);
To avoid such errors, cast the function result with an appropriate maximum length; for example:
SELECT COUNT(*) FROM test1 a WHERE (a.col1 + CAST(SPACE(4-LENGTH(a.col1)) AS VARCHAR(4)) + a.col2 + CAST(SPACE(2-LENGTH (a.col2)) AS VARCHAR(4))) IN (SELECT (b.col3) FROM test1 b);

The errors are more likely with a page size of 64K or a multibyte collation.

Note: For information on string functions that support the LONG BINARY and LONG VARCHAR data types, see Function Support in Unstructured Data Analytics.
Related reference
ASCII Function [String]
BIT_LENGTH Function [String]
BYTE_LENGTH Function [String]
CHAR function [String]
CHAR_LENGTH Function [String]
CHARINDEX Function [String]
DIFFERENCE Function [String]
GRAPHICAL_PLAN Function [String]
HTML_PLAN Function [String]
INSERTSTR Function [String]
LCASE Function [String]
LEFT Function [String]
LEN Function [String]
LENGTH Function [String]
LOCATE Function [String]
LOWER Function [String]
LTRIM Function [String]
PATINDEX Function [String]
REPEAT Function [String]
REPLACE Function [String]
REPLICATE Function [String]
REVERSE Function [String]
RIGHT Function [String]
RTRIM Function [String]
SIMILAR Function [String]
SORTKEY Function [String]
SOUNDEX Function [String]
SPACE Function [String]
STR Function [String]
STR_REPLACE Function [String]
STRING Function [String]
STRTOUUID Function [String]
STUFF Function [String]
SUBSTRING Function [String]
SUBSTRING64 Function [String]
UCASE Function [String]
UPPER Function [String]
UUIDTOSTR Function [String]