DSQL, PSQL

    Syntax

    INTEGER

    Description

    Gives the length in bytes (octets) of the input string. For multi-byte character sets, this may be less than the number of characters times the “formal” number of bytes per character as found in RDB$CHARACTER_SETS.

    With arguments of type CHAR, this function takes the entire formal string length (i.e. the declared length of a field or variable) into account. If you want to obtain the “logical” byte length, not counting the trailing spaces, right- the argument before passing it to OCTET_LENGTH.

    Since Firebird 2.1, this function fully supports text s of any length and character set.

    Examples

    1. select octet_length('Hello!') from rdb$database
    2. -- returns 6
    3. select octet_length(_iso8859_1 'Grüß di!') from rdb$database
    4. select octet_length
    5. (cast (_iso8859_1 'Grüß di!' as varchar(24) character set utf8))
    6. select octet_length
    7. (cast (_iso8859_1 'Grüß di!' as char(24) character set utf8))
    8. from rdb$database

    See also

    BIT_LENGTH(),