Name

length — Get length of argument

Synopsis

integer length ( in arg any );
 

Description

Returns the length of its argument.

Table 24.51. Value returned by length by argument datatype

Argument type Value returned
string number of characters
array number of elements
NULL zero
LOB length if known (see below)
string_session number of bytes written into the session
composite sum of byte lengths of elements consisting the composite

[Note] Note

In case of a LOB that does not have a length as in the case of one supplied by a client with SQLPutData and not yet stored, a zero is returned.

Parameters

arg

Any type that can be tested for length.

Return Values

Integer length of the argument

Errors

Table 24.52. Errors signalled by length

sqlstate error code error text  
22023 SR015 Function length is not applicable to XML tree entity Length cannot calculate a length for a non-persistent XML entity.
22023 SR016 Function length does not handle arguments of type x

An invalid data type was passed as an argument to length


Examples

Example 24.205. Some uses of length()

SQL> select length('abacus'), length (NULL);
callret   callret
INTEGER   INTEGER
_______________________________________________________________________________

6         0

1 Rows. -- 11 msec.
SQL> select max (length (ProductName)) from Demo.demo.Products;
flag
INTEGER
_______________________________________________________________________________

32

1 Rows. -- 61 msec.