Subject Re: [firebird-support] Default field value?
Author Helen Borrie
At 12:48 AM 4/11/2003 -0500, you wrote:
>Helen Borrie wrote:
>
> > At 09:56 PM 3/11/2003 -0500, you wrote:
> >
> >
> >>Hello all,
> >>
> >>Is there a way to insert the current time into a timestamp field is is
> >>null? For instance,
> >>
> >>SELECT Time1, Time2 FROM MyTabe;
> >>
> >>If either the values is null, I would like to have the curren time
> >>filled in...
> >
> >
> > What database and version?
> >
> > And do you mean you want to *store* current time automatically if null, or
> > you want to *output* current time if null is stored?
> >
>
>Hi Helen,
>
>Sorry, I should have been more clear. I am using 1.5 RC6 and I would
>like the value to be visible within the query without saving the value
>to the db if that is possible.
>
>Thanks again,

OK, then look at the new functions CASE, COALESCE and NULLIF.

COALESCE should do it.

SELECT Time1, Time2 FROM MyTabe;

to
SELECT
...
COALESCE(Time1, CURRENT_TIME) AS Time_1,
COALESCE(Time2, CURRENT_TIME) AS Time_2,
...

h.