21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Important<br />

See also: FLOOR()<br />

Internal functions<br />

If the external function CEILING is declared in your database, it will override the internal function CEILING<br />

(but not CEIL). To make the internal function available, DROP or ALTER the external function (UDF).<br />

CHAR_LENGTH(), CHARACTER_LENGTH()<br />

Available in: DSQL, PSQL<br />

Added in: 2.0<br />

Changed in: <strong>2.1</strong><br />

Description: Gives the length in characters of the input string.<br />

Note<br />

With arguments of type CHAR, this function returns the formal string length (i.e. the declared length of a field or<br />

variable). If you want to obtain the “logical” length, not counting the trailing spaces, right-TRIM the argument<br />

before passing it to CHAR[ACTER]_LENGTH.<br />

Result type: INTEGER<br />

Syntax:<br />

CHAR_LENGTH (str)<br />

CHARACTER_LENGTH (str)<br />

BLOB support: Since <strong>Firebird</strong> <strong>2.1</strong>, this function fully supports text BLOBs of any length and character set.<br />

Examples:<br />

select char_length('Hello!') from rdb$database<br />

-- returns 6<br />

select char_length(_iso8859_1 'Grüß di!') from rdb$database<br />

-- returns 8<br />

select char_length<br />

(cast (_iso8859_1 'Grüß di!' as varchar(24) character set utf8))<br />

from rdb$database<br />

-- returns 8; the fact that ü and ß take up two bytes each is irrelevant<br />

select char_length<br />

(cast (_iso8859_1 'Grüß di!' as char(24) character set utf8))<br />

from rdb$database<br />

-- returns 24: all 24 CHAR positions count<br />

See also: BIT_LENGTH(), OCTET_LENGTH<br />

132

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!