Previous Topic: Left JustifyNext Topic: Logarithm


Length

The length function returns the length (number of characters) of a string value.

Syntax:

►►─┬─ SLEN ──────────┬─ (string) ─────────────────────────────────────────────►◄
   ├─ SLENGTH ───────┤
   └─ STRING-LENGTH ─┘

Invocation names:

SLEN
SLENGTH
STRING-LENGTH

Parameters:

(string)

Specifies the string value whose length is determined.

To calculate the length of a string value, excluding leading and trailing spaces, use the length function in conjunction with the extract function.

Example:

This example determines the length of a name contained in EMP-FIRST-NAME-0415 (PIC X(10)). The value of EMP-FIRST-NAME is 'ELMER '.

select slength(extract(emp-first-name-0415))
 from employee

  'ELMER'

  5