Added in: 1.0
Changed in: 1.5
A line starting with "
--" (two dashes) is a comment and will be ignored. This also makes it easy to quickly comment out a line
In Firebird 1.5 and up, the "
--" can be placed anywhere on the line, e.g. after an SQL statement. Everything from the double dash to the end of the line will be ignored.
-- a table to store our valued customers in: create table Customers ( name varchar(32), added_by varchar(24), custno varchar(8), purchases integer -- number of purchases )
Notice that the second comment is only allowed in Firebird 1.5 and up.
Added in: IB
When converting a string literal to a
TIMESTAMP, Firebird allows the use of a shorthand "C-style" cast. This feature already existed in InterBase 6, but was never properly documented.
update People set AgeCat = 'Old' where BirthDate < date '1-Jan-1943' insert into Appointments (Employee_Id, Client_Id, App_date, App_time) values (973, 8804, date 'today' + 2, time '16:00') new.lastmod = timestamp 'now';
Added in: 1.5
CASE construct returns exactly one value from a number of possibilities. There are two syntactic variants:
- The simple
CASE, comparable to a Pascal
caseor a C
- The searched
CASE, which works like a series of
if ... else if ... else ifclauses.
CASE <expression> WHEN <exp1> THEN result1 WHEN <exp2> THEN result2 ... [ELSE defaultresult] END
When this variant is used,
<expression> is compared to
<exp2> etc., until a match is found, upon which the corresponding result is returned. If there is no match and there is an
defaultresult is returned. If there is no match and no
NULL is returned.
The match is determined with the "
=" operator, so if
NULL, it won't match any of the
<expN>s, not even those that are
The results don't have to be literal values: they may also be field or variable names, compound expressions, or
select name, age, case upper(sex) when 'M' then 'Male' when 'F' then 'Female' else 'Unknown' end, religion from people
CASE WHEN <bool_exp1> THEN result1 WHEN <bool_exp2> THEN result2 ... [ELSE defaultresult] END
<bool_expN>s are tests that give a ternary Boolean result:
NULL. The first expression evaluating to
TRUE determines the result. If no expression is
TRUE and there is an
defaultresult is returned. If no expression is
TRUE and there is no
NULL is returned.
As with the simple
CASE, the results don't have to be literal values: they may also be field or variable names, compound expressions, or
CanVote = case when Age >= 18 then 'Yes' when Age < 18 then 'No' else 'Unsure' end;