Search code examples
sqloraclecastingoledbunion

"Unsupported type" warning when using UNION ALL SQL statement with Oracle OleDB


I've got this strange error that I just can't explain...

I have a software that was using ODBC as main connector for the last years. Now the software allows to use OleDB too, which I would prefer for several reasons. Now the funny thing is:
The SQL query that is perfectly working with the Oracle ODBC driver does not work with the Oracle OleDB driver.
For one I have to cast every numeric value with CAST AS, but that's the easy part I already put behind me. So when run seperately, the queries are working now. However as soon as I do a "UNION ALL" with these queries, I get an "unsupported type" warning from the software - just as if I had forgotten to CAST the numeric value(s). Sadly I don't get any more debug information from the software, but my guess is that somehow the SQL statement has to be altered for the Oracle OleDB driver.

Here is the query:

SELECT
  string1 AS Name1
  string2 AS Name2
  CAST (int1 AS INT) AS Year
  CAST (int2 AS INT) AS Period
FROM
  database1
WHERE
  int1 = 2017 AND int2 = 1

UNION ALL

SELECT
  string1 AS Name1
  string2 AS Name2
  CAST (int1 AS INT) AS Year
  CAST (int2 AS INT) AS Period
FROM
  database2
WHERE
  int1 = 2017 AND int2 = 1

Has anyone ever ran into a problem like that?


Solution

  • Turns out nothing was wrong with my query - it looks like a bug in the software, as the exact same query is working just fine (even without CAST) in Excel (with the same OleDB provider etc.). Well, trying another program could have saved me quite some hours of work.

    Anyway I'd like to thank all of you for trying to help me!