DBAtlas · Database operations atlas

42804: datatype_mismatch

PostgreSQL

What does it mean?

The expected data type and the supplied data type do not match. For example, assigning a value of the wrong type to a column, CASE branches returning different types, or UNION branches whose types do not line up.

Why does it happen?

An assignment incompatible with the column type; CASE/COALESCE branches producing different types; corresponding columns in a UNION having different types; a RETURNed value not matching the function's return type; a non-boolean where a boolean is expected.

How to fix it

Cast the expression to the correct type: value::integer or CAST(value AS numeric). Make all CASE branches return the same type. In a UNION, align the types of corresponding columns on both sides. Make sure the WHERE condition yields a boolean.

Open in DBAtlas →

More from this engine