SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-24
CHAR_LENGTH Function
CHAR_LENGTH Function
Considerations for CHAR_LENGTH
SQL/MP Considerations for CHAR_LENGTH
Examples of CHAR_LENGTH
The CHAR_LENGTH function returns the number of characters in a string. You can
also use CHARACTER_LENGTH.
string-value-expression
specifies the string value expression for which to return the length in characters.
NonStop SQL/MX returns the result as a two-byte signed integer with a scale of
zero. If string-value-expression is null, NonStop SQL/MX returns a length of
null. See Character Value Expressions on page 6-37.
Considerations for CHAR_LENGTH
CHAR and VARCHAR Operands
For a column declared as fixed CHAR, NonStop SQL/MX returns the maximum length
of that column. For a VARCHAR column, NonStop SQL/MX returns the actual length of
the string stored in that column.
SQL/MP Considerations for CHAR_LENGTH
Similarity to OCTET_LENGTH Function
The CHAR_LENGTH and OCTET_LENGTH functions are similar. The
CHAR_LENGTH function returns the number of characters in a string, and the
OCTET_LENGTH function returns the number of bytes in a string.
For example, suppose that an SQL/MP table has been created in this way:
CREATE TABLE tab (col_kanji CHAR(10) CHARACTER SET KANJI,
col_char CHAR(10));
This row is inserted into the table:
INSERT INTO tab VALUES (_KANJI'kkkk', 'ccc');
CHAR[ACTER]_LENGTH (string-value-expression)