开发者

spring stored prod return values

my stored prod returns a list of records, how do i handle the return values? I tried using开发者_高级运维 a rowmapper like in my jdbcTemplate.query methods but i can't get it to work.

public void executeClientSurveyProcedure(final Date startDate, final Date endDate) {
  List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
  declaredParameters.add(new SqlParameter(Types.DATE));
  declaredParameters.add(new SqlParameter(Types.DATE));

  jdbcTemplate.call(new CallableStatementCreator() {
    public CallableStatement createCallableStatement(Connection con) throws SQLException {
      CallableStatement cs = con.prepareCall("{call clientsurvey(?, ?)}");
      cs.setDate(1, new java.sql.Date(startDate.getTime()));
      cs.setDate(2, new java.sql.Date(endDate.getTime()));
      return cs;
    }
  }, declaredParameters);

}


Your stored procedure needs another parameter, an OUT parameter where you will receive a cursor to iterate.


You probably need to pass in the output variable where the return value will be stored. Or see this post on a similar question How to call stored procedure to read return value and out parameter both in Spring?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜