SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
O-4
OCTET_LENGTH Function
OCTET_LENGTH Function
The OCTET_LENGTH function returns the length of a character string in bytes.
character-string
specifies the string for which the length is to be returned.
Considerations—OCTET LENGTH Function
SQL returns the result as a two-byte signed integer with a scale of zero.
If character-string is a null value, SQL returns a length of null.
For a column declared as a fixed CHAR, SQL returns the maximum length of that
column. For a VARCHAR column, SQL returns the actual length of the string
stored in that column.
The OCTET_LENGTH and CHAR_LENGTH functions are similar. The
CHAR_LENGTH function returns the number of characters in the string. The result
of both functions is the same for single-byte character data types. For multibyte
character data types, the two functions return different results.
Examples—OCTET LENGTH Function
This example returns the value 6:
OCTET_LENGTH ( "Robert")
This example returns the value 6:
OCTET_LENGTH ( _KANJI "abcdef")
OCTET_LENGTH (character-string)
where character-string is:
{string-literal }
{column-name }
{param-name }
{host-var-name }
{UPSHIFT function }
{character-expression}