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

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-25
Examples of CHAR_LENGTH
This SELECT statement returns the same values for the character length and the octet
length of the ISO88591 column. One character of an ISO88591 character set is
equivalent to one byte.
SELECT CHAR_LENGTH(col_char) AS CHARLENGTH_CHAR,
OCTET_LENGTH(col_char) AS OCTETLENGTH_CHAR
FROM tab;
CHARLENGTH_CHAR OCTETLENGTH_CHAR
--------------- ----------------
10 10
--- 1 row(s) selected.
This SELECT statement returns the same values for the character length and the octet
length of the KANJI column.
SELECT CHAR_LENGTH(col_kanji) AS CHARLENTH_KANJI,
OCTET_LENGTH(col_kanji) AS OCTETLENGTH_KANJI
FROM tab;
CHARLENTH_KANJI OCTETLENGTH_KANJI
--------------- -----------------
10 20
--- 1 row(s) selected.
Examples of CHAR_LENGTH
This function returns 12 as the result. The concatenation operator is denoted by
two vertical bars (||).
CHAR_LENGTH ('ROBERT' || ' ' || 'SMITH')
The string '' is the null (or empty) string. This function returns 0 (zero):
CHAR_LENGTH ('')
The DEPTNAME column has data type CHAR(12). Therefore, this function always
returns 12:
CHAR_LENGTH (deptname)