title: Why does the Oracle database query (Long datatype in Oracle database table's column) not execute in QueryDatabaseTable Apache Nifi?
body: <p>I have a Oracle database with a column setup as '<code>long</code>' data type. The column has <code>XML</code> data. I am trying to transfer the data from Oracle to Bigquery.</p>
  
  <p>I tried the following setup and it worked perfectly: </p>
  
  <pre><code>ExecuteSQL -&gt; AvroToJson -&gt;PutBigQueryBatch
  </code></pre>
  
  <p>However when I tried to do a incremental load with the following setup, it threw an error:</p>
  
  <pre><code>QueryDatabaseTable -&gt; AvroToJson -&gt;PutBigQueryBatch
  </code></pre>
  
  <p>I tried to look into the issue and found the Github <a href="https://github.com/apache/nifi/commit/68a49cfad04df2f467f9529c0fc1b6daf1781192" rel="nofollow noreferrer">support request</a> which is resolved. Is this bug or is there a mistake I make?</p>
  
  <p>Error: </p>
  
  <pre><code>2020-01-14 19:24:56,184 ERROR [Timer-Driven Process Thread-41] o.a.n.p.standard.QueryDatabaseTable QueryDatabaseTable[id=016f11ea-e0e7-1523-fbf7-428dad259c96] Unable to execute SQL select query SELECT * FROM (select * from table) table due to org.apache.nifi.processor.exception.ProcessException: Error during database query or conversion of records.: org.apache.nifi.processor.exception.ProcessException: Error during database query or conversion of records.
  org.apache.nifi.processor.exception.ProcessException: Error during database query or conversion of records.
      at org.apache.nifi.processors.standard.AbstractQueryDatabaseTable.lambda$onTrigger$0(AbstractQueryDatabaseTable.java:295)
      at org.apache.nifi.controller.repository.StandardProcessSession.write(StandardProcessSession.java:2730)
      at org.apache.nifi.processors.standard.AbstractQueryDatabaseTable.onTrigger(AbstractQueryDatabaseTable.java:291)
      at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1176)
      at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:213)
      at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
      at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: org.apache.nifi.processor.exception.ProcessException: java.sql.SQLException: Stream has already been closed
      at org.apache.nifi.processors.standard.sql.DefaultAvroSqlWriter.writeResultSet(DefaultAvroSqlWriter.java:51)
      at org.apache.nifi.processors.standard.AbstractQueryDatabaseTable.lambda$onTrigger$0(AbstractQueryDatabaseTable.java:293)
      ... 13 common frames omitted
  Caused by: java.sql.SQLException: Stream has already been closed
      at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:156)
      at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:126)
      at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:201)
      at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:450)
      at oracle.jdbc.driver.CharCommonAccessor.getObject(CharCommonAccessor.java:788)
      at oracle.jdbc.driver.OracleResultSetImpl.getObject(OracleResultSetImpl.java:1026)
      at org.apache.commons.dbcp2.DelegatingResultSet.getObject(DelegatingResultSet.java:733)
      at org.apache.commons.dbcp2.DelegatingResultSet.getObject(DelegatingResultSet.java:733)
      at org.apache.nifi.util.db.JdbcCommon.convertToAvroStream(JdbcCommon.java:337)
      at org.apache.nifi.processors.standard.sql.DefaultAvroSqlWriter.writeResultSet(DefaultAvroSqlWriter.java:49)
      ... 14 common frames omitted
  </code></pre>
  
  <p>I tried to set <code>Normalise Table/ Column Names</code> along with <code>Avro Logical Type</code> to both <code>True</code> and <code>False</code> in all four combinations, it still threw an error. Is there any known fix for this?</p>