DB2 Version 9.7 for Linux, UNIX, and Windows

OCTET_LENGTH scalar function

Read syntax diagramSkip visual syntax diagram
>>-OCTET_LENGTH--(--expression--)------------------------------><

The schema is SYSIBM.

The OCTET_LENGTH function returns the length of expression in octets (bytes).

expression
An expression that returns a value that is a built-in string data type.

The result of the function is INTEGER. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

The length of character or graphic strings includes trailing blanks. The length of binary strings includes binary zeroes. The length of varying-length strings is the actual length and not the maximum length.

For greater portability, code your application to be able to accept a result of data type DECIMAL(31).

Examples: