2012-08-29 4 views
1

나는 봄 JDBC 템플릿을 사용하고,org.postgresql.util.PSQLException : 열 인덱스가 범위를 벗어 :

나는 다음과 같은 쿼리를 실행
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) })); 

, 내가 열 인덱스가 범위를 벗어있어 : 1 , 열 수 : 0 .; 중첩 예외는 org.postgresql.util.PSQLException입니다.

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 $$ ; "; 

오류 추적은 다음과 같습니다

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) 

고맙습니다, 나 좀 도와주세요 ..

+0

'DO'블록은 프로 시저가 아니므로 CallableStatement를 사용할 수 없다고 생각합니다. 정규 PrepareStatement를 사용하고 대신에'execute()'를 사용해보십시오. CallableStatement는 내가 잘못하지 않았다면 스토어드 프로 시저에만 사용됩니다. –

답변

0

오류 메시지는 다음 반환 된 열을 더 기대 의미합니다.

관련 문제