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.

Result type: INTEGER<br />

Syntax:<br />

BIT_LENGTH (str)<br />

Internal functions<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 bit_length('Hello!') from rdb$database<br />

-- returns 48<br />

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

-- returns 64: ü and ß take up one byte each in ISO8859_1<br />

select bit_length<br />

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

from rdb$database<br />

-- returns 80: ü and ß take up two bytes each in UTF8<br />

select bit_length<br />

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

from rdb$database<br />

-- returns 208: all 24 CHAR positions count, and two of them are 16-bit<br />

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

Available in: DSQL, ESQL, PSQL<br />

Added in: IB<br />

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

CAST()<br />

Description: CAST converts an expression to the desired datatype or domain. If the conversion is not possible,<br />

an error is raised.<br />

Result type: User-chosen.<br />

Syntax:<br />

CAST (expression AS {datatype | [TYPE OF] domain})<br />

Shorthand syntax:<br />

Alternative syntax, supported only when casting a string literal to a DATE, TIME or TIMESTAMP:<br />

datatype 'date/timestring'<br />

This syntax was already available in InterBase, but was never properly documented.<br />

129

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

Saved successfully!

Ooh no, something went wrong!