NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
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
The following example returns the value 6:
OCTET_LENGTH ( "Robert")
The following example returns the value 6:
OCTET_LENGTH ( _KANJI "abcdef")
OPEN Statement
OPEN is a DML statement that opens a cursor in a host program. OPEN executes the
SELECT associated with the cursor, positions the cursor before the first row selected,
and returns statistics to the SQLSA.
OCTET_LENGTH (character-string)
where character-string is:
{string-literal }
{column-name }
{param-name }
{host-var-name }
{UPSHIFT function }
{character-expression}