先调用pg的函数生成cursor,再fetch all返回游标数据集.
JSONData lvRet=new JSONData();
TransJdbcTemplate lvTj = ContextHolder.getTransJdbcTemplate();
lvTj.doTransactionBatch(new TransCallback() {
@Override
public void onExecute(JdbcTemplate pvJt, NamedParameterJdbcTemplate pvNamedJt) throws Exception {
Map<String,Object> lvParams=new HashMap<String,Object>();
try{
lvParams.put("date1", Util.deformatDatetime(pvsDate, "dd/MMM/yyyy"));
lvParams.put("date2", Util.deformatDatetime(pvsDate, "dd/MMM/yyyy"));
lvParams.put("line", pvsLine);
lvParams.put("series_",pvsSeries);
lvParams.put("station",pvsStation);
pvNamedJt.execute("select * from fun_741_top10_by_date_line_series(:date1,:date2, :line,:series_,:station,'ref'); ",lvParams,
new PreparedStatementCallback<Boolean>() {
@Override
public Boolean doInPreparedStatement(PreparedStatement ps)
throws SQLException, DataAccessException {
ps.execute();
return null;
}
});
lvRet.result= pvNamedJt.queryForList("fetch all in ref",(Map<String, ?>)null);
}
catch (Exception e){
lvRet.errCode=1;
lvRet.errMsg=e.getMessage();
throw e;
}
}
});
return lvRet;