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.

Example:<br />

select name,<br />

age,<br />

case upper(sex)<br />

when 'M' then 'Male'<br />

when 'F' then 'Female'<br />

else 'Unknown'<br />

end,<br />

religion<br />

from people<br />

Searched CASE<br />

Syntax:<br />

CASE<br />

WHEN THEN result<br />

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

[ELSE defaultresult]<br />

END<br />

Miscellaneous language elements<br />

Here, the s are tests that give a ternary boolean result: TRUE, FALSE, or NULL. The first expression<br />

evaluating to TRUE determines the result. If no expression is TRUE and there is an ELSE clause, defaultresult<br />

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

As with the simple CASE, the results don't have to be literal values: they may also be field or variable names,<br />

compound expressions, or NULL literals.<br />

Example:<br />

CanVote = case<br />

when Age >= 18 then 'Yes'<br />

when Age < 18 then 'No'<br />

else 'Unsure'<br />

end;<br />

9

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

Saved successfully!

Ooh no, something went wrong!