Total Pageviews

2014/03/05

How to resolve ORA-01790

Problem
When I use UNION ALL syntax to union two select SQL statement, Oracle throw "ORA-01790 expression must have same datatype as corresponding expression" error message.

This error result from I would like to union two result with different data type.

Solution
You can make good of CAST function to cast into the same data type and do union all.

For example. 
SELECT CAST(NVL(FMS406FB.DAY_RSLT, 0) AS NVARCHAR2(30)) DAY_RSLT --每日結存數
FROM .....

Reference
[1] http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions016.htm

No comments: