title: Incompatible datatype in union on Oracle
body: <p>Folks!</p>
  
  <p>Our ORM (Entity Framework) in conjunction to our Oracle Provider (Devart) is generating some SQL that Oracle is unable to execute. I'm not sure who causes the problem, perhaps Devart generates an SQL that can be run given that we have the environment set up.</p>
  
  <p>There's two possibilities I can think of:</p>
  
  <ul>
  <li>Devart generates garbage;</li>
  <li>Oracle is not set up properly.</li>
  </ul>
  
  <p>I think it would be rather difficult to provide Devart with a sample so that they could run into the same situation (I've asked them <a href="http://forums.devart.com/viewtopic.php?f=1&amp;t=27374" rel="nofollow">here</a>) so let's see the second one.</p>
  
  <p>Code that doesn't work:</p>
  
  <pre><code>SELECT        TO_CHAR(NULL) AS EXPR2
  FROM            SYS.DUAL
  UNION ALL
  SELECT        TO_NUMBER(NULL) AS EXPR2
  FROM            SYS.DUAL DUAL_1
  </code></pre>
  
  <p>Code that works:</p>
  
  <pre><code>SELECT        TO_NUMBER(NULL) AS EXPR2
  FROM            SYS.DUAL
  UNION ALL
  SELECT        TO_CHAR(NULL) AS EXPR2
  FROM            SYS.DUAL DUAL_1
  </code></pre>
  
  <p>As can be seen, Oracle does accept different types if the first select brings a number column. But our provider generates the inverse situation (first char then number).</p>
  
  <p>And the question: There's any setting we need to do in Oracle to accept the first sql sample?</p>
  
  <p>Unfortunately we don't know what generates this pattern but in case you'd like to try, our linq is <a href="http://forums.devart.com/viewtopic.php?f=1&amp;t=27374" rel="nofollow">here</a>.</p>
  
  <p>Thank you.</p>