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.

Examples:<br />

Miscellaneous language elements<br />

update People set AgeCat = 'Old'<br />

where BirthDate < date '1-Jan-1943'<br />

insert into Appointments<br />

(Employee_Id, Client_Id, App_date, App_time)<br />

values<br />

(973, 8804, date 'today' + 2, time '16:00')<br />

new.lastmod = timestamp 'now';<br />

See also: CAST<br />

Available in: DSQL, PSQL<br />

Added in: 1.5<br />

CASE construct<br />

Description: A CASE construct returns exactly one value from a number of possibilities. There are two syntactic<br />

variants:<br />

• The simple CASE, comparable to a Pascal case or a C switch.<br />

• The searched CASE, which works like a series of “if ... else if ... else if” clauses.<br />

Simple CASE<br />

Syntax:<br />

CASE <br />

WHEN THEN result<br />

[WHEN THEN result ...]<br />

[ELSE defaultresult]<br />

END<br />

When this variant is used, is compared to 1, 2 etc., until a match is found, upon<br />

which the corresponding result is returned. If there is no match and there is an ELSE clause, defaultresult<br />

is returned. If there is no match and no ELSE clause, NULL is returned.<br />

The match is determined with the “=” operator, so if is NULL, it won't match any of the s,<br />

not even those that are NULL.<br />

The results don't have to be literal values: they may also be field or variable names, compound expressions,<br />

or NULL literals.<br />

A shorthand form of the simple CASE construct is the DECODE() function, available since <strong>Firebird</strong> <strong>2.1</strong>.<br />

8

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

Saved successfully!

Ooh no, something went wrong!