Subject Re: [firebird-support] Re: view porting problem
Author Arno Brinkman
Hi,

> > Could you give me only the necessary metadata to reproduce this?
> > What datatypes do the fields EC_UsrID, KV_UsrID, OE_UsrID and
> MD_UsrID have?
>
> CREATE TABLE "m_MDEntries" (
....
> "MD_UsrTS" TIMESTAMP DEFAULT 'NOW',
> "OE_UsrTS" TIMESTAMP,
> "KV_UsrTS" TIMESTAMP,
> "EC_UsrTS" TIMESTAMP,

> (CASE
> WHEN COALESCE(EC_UsrID, 0) <> 0 THEN EC_UsrTS
> WHEN COALESCE(KV_UsrID, 0) <> 0 THEN KV_UsrTS
> WHEN COALESCE(OE_UsrID, 0) <> 0 THEN OE_UsrTS
> WHEN COALESCE(MD_UsrID, 0) <> 0 THEN MD_UsrTS
> ELSE 0
> END) as StatusTS

Aha, i oversee the fact that your output field in the case was different
from it's check. All your outputs are a timestamp except the ELSE and that's
why the engine complains ;-) A 0 (zero) cannot be converted to a timestamp
thus you must consider a timestamp datatype as result for the else. For
example :

(CASE
WHEN COALESCE(EC_UsrID, 0) <> 0 THEN EC_UsrTS
WHEN COALESCE(KV_UsrID, 0) <> 0 THEN KV_UsrTS
WHEN COALESCE(OE_UsrID, 0) <> 0 THEN OE_UsrTS
WHEN COALESCE(MD_UsrID, 0) <> 0 THEN MD_UsrTS
ELSE NULL
END) as StatusTS


Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/

Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep :
news://80.126.130.81