开发者

spring stored prod return values

开发者 https://www.devze.com 2023-02-26 18:24 出处:网络
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.

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

精彩评论

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