Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve Oracle error ORA-01790?

I have two select statements joined by "union". While executing that statement I've got:

Error report: SQL Error: ORA-01790: expression must have same datatype as corresponding expression 01790. 00000 - "expression must have same datatype as corresponding expression"

Maybe you can give me an advise on how to diagnose this problem?

like image 788
Roman Kagan Avatar asked Dec 07 '09 21:12

Roman Kagan


2 Answers

Without looking at your SQL, I would guess that you have columns being UNION'ed that have different data types.

like image 107
Otávio Décio Avatar answered Oct 08 '22 21:10

Otávio Décio


Here's what found:

ORA-01790: expression must have same datatype as corresponding expression

Cause: A SELECT list item corresponds to a SELECT list item with a different datatype in another query of the same set expression.

Action: Check that all corresponding SELECT list items have the same datatypes. Use the TO_NUMBER, TO_CHAR, and TO_DATE functions to do explicit data conversions.

I haven't seen your query, but I am guessing that one select in your union is not selecting the same columns as the other.

like image 37
FrustratedWithFormsDesigner Avatar answered Oct 08 '22 20:10

FrustratedWithFormsDesigner