title: select length of oracle long raw with sql statement
body: <p>storing filedata via a hibernate (using postgresql or oracle 10g/11g) property mapped as</p>
  
  <pre><code>        &lt;property name="fileData" type="binary"&gt;
              &lt;column name="fileData" length="104857600" /&gt;
          &lt;/property&gt;
  </code></pre>
  
  <p>from a java application i need to access the length of the field from the db (i do not want to load whole the object, for performance reasons). i did not find any hibernate (hql) solution to query that information, so i decided to search for features of the different databases that were used. for postgresql i found:</p>
  
  <pre><code>select BIT_LENGTH(filedata) from table
  </code></pre>
  
  <p>which works perfectly (and astonishing fast). now i need something similar for the use with oracle. i already tried </p>
  
  <pre><code>select utl_raw.length(filedata) from table
  </code></pre>
  
  <p>and
      select DBMS_LOB.GETLENGTH(filedata) from table</p>
  
  <p>which both results in the error msg:</p>
  
  <p>"Error: ORA-00997: illegal use of LONG datatype"</p>
  
  <p>is there any possibilty to query the length of that hibernate property on an oracle db without selecting the object itself? </p>
  
  <p>(hibernate creates a "long raw" field on oracle, and a "bytea" field on postgresql)</p>
  
  <p>thx in advance</p>
  
  <p>(addition: statement will be used in a migration-context, newly created filedata entities will get a filesize property programatically)</p>