You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/01/18 12:35:12 UTC

[GitHub] [shardingsphere] odyssey1816 opened a new issue #9080: parameter misalignment occurs when executing `case when` in prepareStatement

odyssey1816 opened a new issue #9080:
URL: https://github.com/apache/shardingsphere/issues/9080


   ## Question
   sharding-jdbc is in the process of upgrading from 4.0.1 to 4.1.1,parameter misalignment occurs when executing `case when`  in prepareStatement
   
   ### SQL
   ```sql
   UPDATE product_sku   
   SET seller_id = ( ( CASE WHEN sku_seq =? THEN ? END ) )   
   WHERE  
    app_id = ?   
    AND product_seq = ?   
    AND sku_seq IN ( ? )  
   ```
   ### test program
   ```sql
       	String sql = "UPDATE product_sku\n" +
       	    "         set seller_id =((case when sku_seq=? then ? end))" +
       	    "        where\n" +
       	    "        app_id = ?\n" +
       	    "        and product_seq = ?\n" +
       	    "        and sku_seq in\n" +
       	    "         (  \n" +
       	    "            ?\n" +
       	    "         )";
       	try (
       	    Connection conn = dataSource.getConnection();
       	    PreparedStatement statement = conn.prepareStatement(sql)) {
       	    statement.setString(1, "seller_id1");
       	    statement.setString(2, "seller_id2");
       	    statement.setString(3, "SL201");
       	    statement.setString(4, "123456");
       	    statement.setString(5, "1234567");
       	    int i = statement.executeUpdate();
       	
       	    System.out.println("");
       	} catch (Exception e) {
       	    e.printStackTrace();
       	}
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #9080: parameter misalignment occurs when executing `case when` in prepareStatement

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #9080:
URL: https://github.com/apache/shardingsphere/issues/9080#issuecomment-774611726


   @odyssey1816 The `case ... when ...` statement is already supported in the latest `5.0.0-alpha` version, you can upgrade to the latest version. 😊


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #9080: parameter misalignment occurs when executing `case when` in prepareStatement

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #9080:
URL: https://github.com/apache/shardingsphere/issues/9080


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org