Learn the cause and how to resolve the ORA-01790 error message in Oracle.
When you encounter an ORA-01790 error, the following error message will appear:
- ORA-01790: expression must have same datatype as corresponding expression
Cause of Error
How to Resolve the Error
The option(s) to resolve this Oracle error are:
Re-write the SELECT statement so that each matching column is the same data type.
For example, if you tried to execute the following UNION query:
SELECT supplier_name FROM orders UNION SELECT quantity FROM orders_audit;
You would receive an error message as follows:
Since the supplier_name column is defined as a varchar2 and the quantity column is defined as a number, these columns can not be matching columns.
SELECT supplier_name FROM orders UNION SELECT TO_CHAR(quantity) FROM orders_audit;
In this example, we've used the TO_CHAR function to convert the quantity column to a data type that is compatible with the supplier_name column.