title: Java JDBC How to Handle Update Query with RETURNING Statement
body: <p>I have a simple sql query which increments version by 1 and returns the current value in postgresql such as:</p>
  
  <pre><code>UPDATE table SET version = version + 1 where id = 'XXX' RETURNING version
  </code></pre>
  
  <p>However I am unable to use it in jdbcTemplate.update statement:</p>
  
  <pre><code>int version = jdbcTemplate.update(sqlString, new Object[] {id}); 
  </code></pre>
  
  <p>throws exception:</p>
  
  <p><strong>A result was returned when none was expected</strong></p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [UPDATE table SET version = version + 1 where id = ? RETURNING version]; A result was returned when none was expected.; nested exception is org.postgresql.util.PSQLException: A result was returned when none was expected.
  </code></pre>
  
  <p>What is the correct way to use RETURNING statement?</p>