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?
---