LENGTH

The LENGTH function returns an integer equal to the length of the argument in national character positions for arguments of usage NATIONAL and in alphanumeric character positions or bytes for all other arguments. An alphanumeric character position and a byte are equivalent.

The type of the function is integer.

Read syntax diagramSkip visual syntax diagram
Format

>>-FUNCTION LENGTH--(--argument-1--)---------------------------><

argument-1
Can be:
  • An alphanumeric literal or a national literal
  • A data item of any class except DBCS
  • A data item described with usage POINTER, PROCEDURE-POINTER, FUNCTION-POINTER, or OBJECT REFERENCE
  • The ADDRESS OF special register
  • The LENGTH OF special register
  • The XML-NTEXT special register
  • The XML-TEXT special register

The returned value is a nine-digit integer if the ADDR(32) compiler option is specified or an 18-digit integer if the ADDR(64) compiler option is specified and is determined as follows: