Hitachi

Hitachi Advanced Database SQL Reference


8.6.3 LENGTH

Returns the number of characters in the target character string.

Organization of this subsection

(1) Specification format

scalar-function-LENGTH ::= LENGTH(target-data)
 
  target-data ::= value-expression

(2) Explanation of specification format

target-data:

Specifies the target data in which to count the number of characters.

The following specification rules apply:

  • Specify the target data in the form of a value expression. For details about value expressions, see 7.21 Value expression.

  • Specify CHAR, VARCHAR, or STRING type data for the target data.

  • You cannot specify a dynamic parameter by itself for the target data.

(3) Rules

  1. The data type of the execution result is the BIGINT type#.

    #

    If the integer data type format is a legacy format, it will be an INTEGER type.

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. If the target data is a null value, the execution result will be a null value.

  4. If the actual length of the target data is 0 bytes or 0 characters, the execution result value will be 0.

(4) Example

Example:

Determine the number of characters in the data in columns C1 and C2 from table T1.

In this case, the character encoding being used is Unicode (UTF-8).

SELECT LENGTH("C1"),LENGTH("C2") FROM "T1"

[Figure]

In the above example, each space is counted as one character.