Subject Some FB sql questions
Author Yolland, George
Hi,

I would like to extract the 4 digit year from a date. In another database I
work with I have lots of date functions to do this type of thing but I don't
seem to have these types of options with Firebird v 1.0. For example, using
Red Brick I can get the year by a couple of different means, like

EXTRACT(YEAR from INVOICE_DATE)

How would I do something like this in Firebird? I know I can use CAST to
change the data type, like

CAST(INVOICE_DATE as CHAR(10))

but the CAST doesn't let me specify a format or, in this case, the specific
date part I want. Or I just don't know how to make it do it.

Another thing I would like to be able to do is put a default constraint on a
date columns that puts the system date in the column if no value is
provided. How can I do this with Firebird?

I'd also would like to define a check constraint where column must be either
ValueA or ValueB. The language reference isn't very clear on this. The
reference says something like:

CHECK(search_condition)

but doesn't provide my guidance on what search_condition can be.

Finally, I am surprised that the SUBSTR(expr, stort, length) function is not
supported. I don't know if it's part of the SQL standard but every other
dbms I've worked with has supported SUBSTR. Is the capabilities of SUBSTR
implemented in some other way?

Thanks, George

George Yolland Data Warehouse Programmer
Unisys Corporation voice: 480-783-5934
6161 West Erie Street fax: 480-783-5916
Chandler, AZ 85226 <mailto:george.yolland@...>