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.

Internal functions<br />

This gives you control over the type of input field set up by the engine. Please notice that with statement parameters,<br />

you always need a full-syntax cast – shorthand casts are not supported.<br />

Casting to a domain or its type: <strong>Firebird</strong> <strong>2.1</strong> and above support casting to a domain or its base type. When casting<br />

to a domain, any constraints (NOT NULL and/or CHECK) declared for the domain must be satisfied or the cast will<br />

fail. Please be aware that a CHECK passes if it evaluates to TRUE or NULL! So, given the following statements:<br />

create domain quint as int check (value >= 5000)<br />

select cast (2000 as quint) from rdb$database -- (1)<br />

select cast (8000 as quint) from rdb$database -- (2)<br />

select cast (null as quint) from rdb$database -- (3)<br />

only cast number (1) will result in an error.<br />

When the TYPE OF modifier is used, the expression is cast to the base type of the domain, ignoring any constraints.<br />

With domain quint defined as above, the following two casts are equivalent and will both succeed:<br />

select cast (2000 as type of quint) from rdb$database<br />

select cast (2000 as int) from rdb$database<br />

If TYPE OF is used with a (VAR)CHAR type, its character set and collation are retained:<br />

create domain iso20 varchar(20) character set iso8859_1;<br />

create domain dunl20 varchar(20) character set iso8859_1 collate du_nl;<br />

create table zinnen (zin varchar(20));<br />

commit;<br />

insert into zinnen values ('Deze');<br />

insert into zinnen values ('Die');<br />

insert into zinnen values ('die');<br />

insert into zinnen values ('deze');<br />

select cast(zin as type of iso20) from zinnen order by 1;<br />

-- returns Deze -> Die -> deze -> die<br />

select cast(zin as type of dunl20) from zinnen order by 1;<br />

-- returns deze -> Deze -> die -> Die<br />

Casting BLOBs: Successful casting to and from BLOBs is possible since <strong>Firebird</strong> <strong>2.1</strong>.<br />

Available in: DSQL, PSQL<br />

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

CEIL(), CEILING()<br />

Description: Returns the smallest whole number greater than or equal to the argument.<br />

Result type: BIGINT or DOUBLE PRECISION<br />

Syntax:<br />

CEIL[ING] (number)<br />

131

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

Saved successfully!

Ooh no, something went wrong!