[ 
https://issues.apache.org/jira/browse/NIFI-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16353319#comment-16353319
 ] 

ASF GitHub Bot commented on NIFI-4561:
--------------------------------------

Github user patricker commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2243#discussion_r166180285
  
    --- Diff: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ExecuteSQL.java
 ---
    @@ -202,56 +205,63 @@ public void process(InputStream in) throws 
IOException {
                 st.setQueryTimeout(queryTimeout); // timeout in seconds
     
                 logger.debug("Executing query {}", new Object[]{selectQuery});
    -            boolean results = st.execute(selectQuery);
    +            boolean hasResults = st.execute(selectQuery);
    +            boolean hasUpdateCount = st.getUpdateCount() != -1;
    --- End diff --
    
    I haven't run into any issues with calling `execute` instead of 
`executeUpdate`. I did some additional research and found the following 
concerning `execute`: https://stackoverflow.com/a/16625802/328968
    
    > "*Executes the given SQL statement, which may return multiple results. In 
some (uncommon) situations, a single SQL statement may return multiple result 
sets and/or update counts. Normally you can ignore this unless you are (1) 
executing a stored procedure that you know may return multiple results or (2) 
you are dynamically executing an unknown SQL string.*"
    
    Or the answer after that which provides more details on each type of call, 
`execute`, `executeUpdate`, and `executeQuery`: 
https://stackoverflow.com/a/37509744/328968.


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

Reply via email to