OCTET_LENGTH Function
The OCTET_LENGTH function returns the length of a character string in bytes.
OCTET_LENGTH (string-value-expression)
string-value-expression
specifies the string value expression for which to return the length in bytes. Neoview SQL
returns the result as a 2-byte signed integer with a scale of zero. If
string-value-expression is null, Neoview SQL returns a length of zero. See
Value Expressions" (page
Considerations for OCTET_LENGTH
CHAR and VARCHAR Operands
For a column declared as fixed CHAR, Neoview SQL returns the length of that column as the
maximum number of storage bytes. For a VARCHAR column, Neoview SQL 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
"OCTET_LENGTH Function" (page
Example of OCTET_LENGTH
If a character string is stored as two bytes for each character, this function returns the value 12.
Otherwise, the function returns 6:
OCTET_LENGTH ('Robert')
380
SQL Functions and Expressions
208).
380).
"Character