title: Oracle ResultSetMetaData getPrecision/getScale
body: <p>I'm using Oracle's JDBC thin driver (10.2.0.3) for connecting to an Oracle 10g database. I'd like to get information about the database columns, so I use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html" rel="nofollow noreferrer">ResultSetMetaData</a>. The most important information I need is the type of the column and the length, so I use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html#getColumnType(int)" rel="nofollow noreferrer">getColumnType</a>, <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html#getPrecision(int)" rel="nofollow noreferrer">getPrecision</a>, and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSetMetaData.html#getScale(int)" rel="nofollow noreferrer">getScale</a> methods.</p>
  
  <p>It works for a simple query (<code>select * from tablename</code>) if the column type is "simple" like <code>VARCHAR2(50), NUMBER(5), NUMBER(6,2)</code>. If I have a more complex query (<code>select count(*) from tablename</code>) or a query based on a view which contains some complex calculation, the methods give weird results like:</p>
  
  <ul>
  <li><code>getScale</code>: -127</li>
  <li>both <code>getPrecision</code> and <code>getScale</code> is 0</li>
  <li><code>getPrecision</code>: -1</li>
  </ul>
  
  <p>Setting the <code>oracle.jdbc.J2EE13Compliant</code> connection property to <code>true</code> (as suggested by several webpages) eliminates getScale=-127 but still returns 0/0 result.</p>
  
  <p>Most likely I have to create a workaround for these weird results, but first I need at least a comprehensive documentation about the behavior of Oracle's ResultSetMetaData. For instance a huge table with the meaning of getPrecision/getScale for all the SQL types would be great. Is there a documentation like this somewhere?</p>