Subject | Re: [firebird-support] Datatypes are not comparable in expression COALESCE. |
---|---|
Author | Helen Borrie |
Post date | 2010-02-27T21:37:29Z |
At 04:33 AM 28/02/2010, you wrote:
You cannot compare anything with NULL, but you can compare a date with a date, i.e., this is OK:
select
....,
coalesce (MyDate, CURRENT_DATE) as SomeDate,
....
And SomeDate will be returned as a DATE field. If MyDate is NULL, then SomeDate will be today's date.
The usual rules apply for data type compatibility and use of literals, so the following would not be valid:
select
....,
coalesce (MyDate, 'today') as SomeDate,
You would have to cast the literal:
select
....,
coalesce (MyDate, (cast('today' as DATE))) as SomeDate,
Better that you provide an example of the usage of COALESCE that doesn't work for you so we can figure out why.
./heLen
>Hello allThat is a "dark" question, Marcin! ;-) What are you trying to do with COALESCE?
>
>Is there a list of datatypes that are not comparable in COALESCE?
>
>'Date' is probably one of them...
You cannot compare anything with NULL, but you can compare a date with a date, i.e., this is OK:
select
....,
coalesce (MyDate, CURRENT_DATE) as SomeDate,
....
And SomeDate will be returned as a DATE field. If MyDate is NULL, then SomeDate will be today's date.
The usual rules apply for data type compatibility and use of literals, so the following would not be valid:
select
....,
coalesce (MyDate, 'today') as SomeDate,
You would have to cast the literal:
select
....,
coalesce (MyDate, (cast('today' as DATE))) as SomeDate,
Better that you provide an example of the usage of COALESCE that doesn't work for you so we can figure out why.
./heLen