Subject Re: [firebird-support] COALESCE
Author Ivan Prenosil
> SELECT FIRST 10
> V.Z_Type,
> COALESCE(Z_Date, 'not defined') AS Pol
> ...
>
> Z_Date is a DATE column.
>
> The problem is that the date is displayed as 'YYYY-MM-DD',
> while my preferred setting is 'DD.MM.YYYY'.
> When I just select the Z_Date column without using COALESCE,
> the dates display correctly.
>
> I guess that the date is converted to a different type (varchar?)
> by COALESCE, so that my client (IBO) does not know how to format
> the date.
>
> Does anybody know what's going on?
> Of course, I would be glad about a small workaround ;-)

Each column of result set must have determined its datatype,
i.e. datatype can't change dynamically for each fetched row.
Result type of COALESCE expression is determined by its first item,
i.e. DATE. String 'not defined' can't be converted to DATE, of course.

If you want to return result as VARCHAR (and you have no other choice
if you want to do that test on the server), cast date to varchar, i.e.
COALESCE(CAST(Z_Date AS VARCHAR(25)), 'not defined') AS Pol

Ivan