NutzCN Logo
分享 oracle 存储过程返回结果集
发布于 2342天前 作者 asdf3309 1882 次浏览 复制 上一个帖子 下一个帖子
标签:

存储过程

Dao dao = new NutDao(sds);   	
    	
    	dao.run(new ConnCallback() {
			@Override
			public void invoke(Connection conn) throws Exception {
				CallableStatement cstm=conn.prepareCall("call detail(?)");
				cstm.registerOutParameter(1, OracleTypes.CURSOR);
				cstm.execute();
			    ResultSet rs = (ResultSet)cstm.getObject(1);
			    
			    final ResultSetMetaData rmd=rs.getMetaData();
			    
			    ResultSetLooping ing = new ResultSetLooping() {
		            protected boolean createObject(int index,
		                                           ResultSet rs,
		                                           SqlContext context,
		                                           int rowCout) {
		                NutMap re = new NutMap();
		                Record.create(re, rs, rmd);
		                list.add(re);
		                return true;
		            }
		        };
		        
		        ing.doLoop(rs, new SqlContext());
		        
		        List<NutMap> re=Lang.collection2list(ing.getList(), NutMap.class);
		    	System.out.println(re);
			}
		});
CREATE OR REPLACE PROCEDURE detail(c OUT sys_refcursor)
is
begin
  open c For select * from x_table;
end detail;

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