title: Is there an function to retrieve the binary XML from oracle result set
body: <p>I am trying to extract the data from XMLTYPE COLUMN "ATTRIBUTE_XML2" STORE AS SECUREFILE BINARY XML from an Oracle 12C database.</p>
  
  <p>I am using this select query in my code:</p>
  
  <pre><code>select xmlserialize(document a.xmlrecord as clob) as xmlrecord from tablename
  
  ResultSet rset = stmt.executeQuery();
  
  OracleResultSet orset = (OracleResultSet) rset;
  while (orset.next()) {
  oracle.sql.CLOB xmlrecord = (oracle.sql.CLOB) orset.getClob(1);
  Reader reader = new BufferedReader(xmlrecord.getCharacterStream()); 
  }
  </code></pre>
  
  <p>Here "<code>orset.getClob</code>" is taking more memory in oracle DB and we are getting out of process memory in the oracle database. Currently we have the XML type storage as CLOB and business is interested to  change it to BINARY XML.</p>
  
  <p>Is there any option for retrieving the binary XML from the oracle result set? </p>
  
  <p>Please note that i have tried "<code>orset.getClob</code>" which results in memory error, since it is changing the binary XML to clob. </p>
  
  <p>Also tried with " <code>XMLType xml = (XMLType) orset.getObject(1);</code>" this is working fine, but it is taking 27 minutes for fetching 1 million XML records.</p>
  
  <p>Whereas the same 1 million completed in 5 minutes if the table type storage is CLOB instead of BINARY XML. </p>
  
  <p>Is there any other option for retrieving the BINARY XML ?</p>