SQL/MX 3.2 Reference Manual (H06.25+, J06.14+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
9-126
OCTET_LENGTH Function
insert into tab1(colB) values(3);
--- 1 row(s) inserted.
insert into tab1 values('four',4);
--- 1 row(s) inserted.
select NVL2(colA,colB,0) as nvl2_value from tab1;
NVL2_VALUE
---------------------
1
0
0
4
OCTET_LENGTH Function
The OCTET_LENGTH function returns the length of a character string in bytes.
string-value-expression
specifies the string value expression for which to return the length in bytes.
NonStop SQL/MX returns the result as a 2-byte signed integer with a scale of zero.
If string-value-expression is null, NonStop SQL/MX returns a length of zero.
See Character Value Expressions on page 6-41.
Considerations for OCTET_LENGTH
CHAR and VARCHAR Operands
For a column declared as fixed CHAR, NonStop SQL/MX returns the length of that
column as the maximum number of storage bytes. For a VARCHAR column,
NonStop SQL/MX returns the length of the string stored in that column as the actual
number of storage bytes.
Similarity to CHAR_LENGTH Function
The OCTET_LENGTH and CHAR_LENGTH functions are similar. The
OCTET_LENGTH function returns the number of bytes, rather than the number of
characters, in the string. This distinction is important for multibyte implementations. For
an example of selecting a double-byte column, see Similarity to OCTET_LENGTH
Function on page 9-24.
OCTET_LENGTH (string-value-expression)