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);
}