NutzCN Logo
问答 nutz 如何获取oracle 存储过程输出参数cursor问题
发布于 3010天前 作者 FWC1994 1909 次浏览 复制 上一个帖子 下一个帖子
标签:

oracle 存储过程

create or replace procedure GetCityStoreData (DataSet out sys_refcursor)
is 
begin
  open DataSet for 
  select 
  min(CityCenter.name) as "name",
  min(CityCenter.x) as "x",
  min(CityCenter.y) as "y", 
  min(SH_STORE.STOREID) as "storeid", 
  code as "code",
  count(*) as "CityCTPcount" 
  from CityCenter left join SH_STORE 
  on SH_STORE.CITYCODE=CityCenter.code 
  group by CityCenter.code;
end;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nutz 获取结果集代码 (出现问题)

Sql sql = Sqls.create("{call GEtCITYSTOREDATA(@cursor)}");
sql.params().set("cursor",OracleTypes.CURSOR);
dao_ora.execute(sql);
ResultSet rs=(ResultSet)sql.params().get("cursor");
JSONArray result=new JSONArray();
while (rs.next()){
	JSONObject ret=new JSONObject();
	ret.put("CityName", rs.getString("name"));
	ret.put("CityCode", rs.getString("code"));
	ret.put("CityX", rs.getString("x"));
	ret.put("CityY", rs.getString("y"));
	if(rs.getString("storeid") != null){
		ret.put("CityCTPcount", rs.getInt("CityCTPcount"));
	}else{
		ret.put("CityCTPcount", 0);
	}					
			result.put(ret);
}
2 回复

出参? 暂不支持. 走JDBC取吧

dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                // 拿到conn,任意发挥.
            }
        });

添加回复
请先登陆
回到顶部