602SQL Documentation Index  

String Length Functions (SQL)

CHAR_LENGTH(arg)  
OCTET_LENGTH(arg)  
BIT_LENGTH(arg)

The functions CHAR_LENGTH, OCTET_LENGTH and BIT_LENGTH return the argument length. The argument must either be a string or binary type (CHAR, NCHAR, CLOB, NCLOB, BLOB, BIT, BINARY). The first function returns the character count, the second returns the length in bytes, and the third returns the length in bits.

The following table shows the results of these functions for the same string. First as CHAR type and then as NCHAR type (2-byte Unicode):

string '602sql' as CHAR as NCHAR
CHAR_LENGTH 6 6
OCTET_LENGTH 6 12
BIT_LENGTH 48 96

SQL properties defined by implementation in 602SQL

602SQL Variations

Example:

Function that returns the length (character count) of a parameter.

FUNCTION DELKACHAR (strpar CHAR (100)) RETURNS INT;
BEGIN
  RETURN (CHAR_LENGTH(strpar));
END

See