Subject Re: [ib-support] define date
Author Helen Borrie
At 10:22 PM 21-03-02 -0800, Daniel Bertin wrote:
>Hi all,
>How should I define a date field so that I can enter a blank (no value )
>into my table.
>
>I tried;
>CREATE DOMAIN T_DATE AS DATE DEFAULT 'NOW' NOT NULL;
>CREATE DOMAIN T_DATE2 AS DATE;
>CREATE DOMAIN T_DATE AS DATE DEFAULT NULL;

There is really no such thing as a "blank date". Even 0 is a date (17
November 1873 or some such). Your choices are:

either
a)
make it NOT NULL and default it to the current server date - you are on the
right
track with sample 1, except that you should use DEFAULT CAST('TODAY' AS
DATE) or DEFAULT CAST(CURRENT_TIMESTAMP AS DATE)

or b)
leave it nullable and ignore it.

>ORDDATE T_DATE
>ORDDATE T_DATE2
>ORDDATE DATE
>
>nothing seems to work, when I post from dbnavigator I get the error
>"field ORDDATE must have a value"

> what should I do?

Server defaults won't work in your client. If you are using Delphi, a NOT
NULL column will have the Required attribute. With IBO (which I think you
use) you can set this attribute off in the ColumnAttributes.Required and/or
assign a client-side default in the DefaultValues property. This is
actually safer than relying on a server default, since server DEFAULTs work
only on inserts, whereas your client can validate an editing user's changes.

Another alternative is to employ Before Insert and Before Update triggers
to test for null and apply a default.

cheers,
Helen

All for Open and Open for All
Firebird Open SQL Database · http://firebirdsql.org ·
http://users.tpg.com.au/helebor/
_______________________________________________________