RSS

ORA-01790 when Union Null and Date

25 Jul

In Oracle 8i or earlierUnion Null and Date Type column will cause ORA-01790: expression must have same datatype as corresponding expression.

-- This query will fail
SELECT PayDate FROM Table1
UNION
SELECT '' FROM Table2

The solution is using To_Date(NULL)instead of Null.

SELECT PayDate FROM Table1
UNION
SELECT To_Date(NULL) FROM Table2

Reference:NULL in union causing ORA-01790

Advertisements
 
Leave a comment

Posted by on July 25, 2012 in Database, Oracle, SQL

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: