[ https://issues.apache.org/jira/browse/NIFI-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16448104#comment-16448104 ]
ASF GitHub Bot commented on NIFI-4561: -------------------------------------- Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2243#discussion_r183382982 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteSQL.java --- @@ -220,17 +224,19 @@ public void onTrigger(final ProcessContext context, final ProcessSession session JdbcCommon.setParameters(st, fileToProcess.getAttributes()); } logger.debug("Executing query {}", new Object[]{selectQuery}); - boolean results = st.execute(); + boolean hasResults = st.execute(); + boolean hasUpdateCount = st.getUpdateCount() != -1; - - while(results){ - FlowFile resultSetFF; - if(fileToProcess == null){ - resultSetFF = session.create(); - } else { - resultSetFF = session.create(fileToProcess); - resultSetFF = session.putAllAttributes(resultSetFF, fileToProcess.getAttributes()); - } + while(hasResults || hasUpdateCount) { + //getMoreResults() and execute() return false to indicate that the result of the statement is just a number and not a ResultSet + if (hasResults) { + FlowFile resultSetFF; + if (fileToProcess == null) { + resultSetFF = session.create(); + } else { + resultSetFF = session.create(fileToProcess); + resultSetFF = session.putAllAttributes(resultSetFF, fileToProcess.getAttributes()); + } final AtomicLong nrOfRows = new AtomicLong(0L); --- End diff -- Could you fix the indentation level here to harmonize it with your changes? > ExecuteSQL Stopped Returning FlowFile for non-ResultSet Queries > --------------------------------------------------------------- > > Key: NIFI-4561 > URL: https://issues.apache.org/jira/browse/NIFI-4561 > Project: Apache NiFi > Issue Type: Bug > Reporter: Peter Wicks > Assignee: Peter Wicks > Priority: Major > > While most people use ExecuteSQL for Select statements, some JDBC drivers > allow you to execute any kind of statement, including multi-statement > requests. > This allowed users to submit multiple SQL statements in one JDBC Statement > and get back multiple result sets. This was part of the reason I wrote > [NIFI-3432]. > After having NIFI-3432 merged, I found that some request types no longer > cause a FlowFile to be generated because there is no ResultSet. Also, if > request types are mixed, such as an insert followed by a Select, then no > ResultSet is returned because the first result is not a result set but an > Update Count. -- This message was sent by Atlassian JIRA (v7.6.3#76005)