gpt4 book ai didi

java - org.postgresql.util.PSQLException : The column index is out of range:

转载 作者:太空宇宙 更新时间:2023-11-04 08:05:11 24 4
gpt4 key购买 nike

我正在使用 spring JDBC 模板,

    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)

谢谢,请帮帮我..

最佳答案

错误消息意味着您期望的列数多于返回的列数。

关于java - org.postgresql.util.PSQLException : The column index is out of range:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12182431/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com