title: org.postgresql.util.PSQLException: The column index is out of range:
body: <p>I am using spring JDBC Template,</p>
  
  <pre><code>    Map resultsMap = getStoryJdbcTemplate().call(
      new CallableStatementCreator() {
  
        public CallableStatement createCallableStatement(Connection pConn)
            throws SQLException {
          CallableStatement callable = pConn.prepareCall(DELETE_STORY);
          callable.setLong(1, pStory.getId());
          callable.setLong(2, pStory.getVersion());
          callable.registerOutParameter(3, Types.INTEGER);
          callable.registerOutParameter(4, Types.BIGINT);
          return callable;
        }
      },
      Arrays.asList(new SqlParameter[] { new SqlParameter(Types.BIGINT), 
          new SqlParameter(Types.BIGINT),
          new SqlOutParameter("rowCount", Types.INTEGER), 
          new SqlOutParameter("version", Types.BIGINT) }));
  </code></pre>
  
  <p>When I executed following query, I got The column index is out of range: 1, number of columns: 0.; nested exception is org.postgresql.util.PSQLException.</p>
  
  <pre><code>    private static final String DELETE_STORY = ""
  
  +"Do $$"      
  + "DECLARE "
  + "   v_rowcount numeric; "
  + "   v_version numeric; "
  + "BEGIN "
  + "     DELETE FROM registrant_stories "
  + "     WHERE registrant_story_id = ? AND version = ? "
  + "     RETURNING version INTO v_version; "
  + "     GET DIAGNOSTICS v_rowcount := ROW_COUNT; "
  + "     ? := v_rowcount; "
  + "     ? := v_version; "
  + "END $$ ; ";
  </code></pre>
  
  <p>Error trace is:</p>
  
  <pre><code>   org.springframework.dao.DataIntegrityViolationException: CallableStatementCallback; SQL []; The column index is out of range: 1, number of columns: 0.; nested exception is org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.
  at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:100)
  </code></pre>
  
  <p>Thanx, Please help me out..</p>