[All]
Expression evaluation not supported error when using COALESCE or CASE
Par: Quinn Wildman
Résumé: The data type of all expressions passed to COALESCE must be the same
Q. I'm using COALESCE or CASE and I'm getting the error "expression evaluation not supported". What might cause this?
A. All expressions passed to COALESCE must be of the same type. All expression returned by CASE must be of the same type. If they are not, the error "expression evaluation not supported" occurs.
Example1:
CREATE TABLE T1 (F1 INTEGER, F2 FLOAT);
SELECT COALESCE(F1,F2) FROM T1;
To solve the problem, cast your expressions so they all result in the same data type. Example:
SELECT COALESCE(CAST(F1 AS FLOAT), F2) FROM T1;
Example 2:
SELECT
CASE RDB$RELATION_ID
WHEN 1 THEN 1
WHEN 2 THEN 2.0
END
FROM RDB$DATABASE;
Solution:
SELECT
CASE RDB$RELATION_ID
WHEN 1 THEN cast(1 as double precision)
WHEN 2 THEN 2.0
END
FROM RDB$DATABASE;
Connect with Us