Subject Re: [firebird-support] Datatypes are not comparable in expression COALESCE.
Author Ivan Prenosil
> I have a table where I have a field COMPLETED_DATE of 'date' type.
> When I insert a record to this table I leave this field null.
>
> Then I'd like to have some 'after update' trigger that would fire when
> COMPLETED date has changed, so I have tried:
>
> IF (COALESCE(OLD.COMPLETED_DATE,0) <> COALESCE(NEW.COMPLETED_DATE, 0))
> THEN ...
>
> I thought that it should work since 'data' type is some kind of
> 'numeric' type. But I was wrong - and got error as in subject.

Everything is stored intetrnally as number, but as datatypes whey are something completely different.
What you want is
IF (OLD.COMPLETED_DATE IS DISTINCT FROM NEW.COMPLETED_DATE)
THEN ...