分类:
2008-10-27 13:38:51
create or replace package pkg_test as type t_ref is ref cursor; procedure p_test(cur_ref out t_ref); end pkg_test; / create or replace package body pkg_test as procedure p_test(cur_ref out t_ref) is begin open cur_ref for 'select * from test'; end p_test; end pkg_test; /
oracle.jdbc.CallableStatement cs = null; String sqlStr = "{call firstpage.getSeniorHighSchool(?,?,?)}"; ResultSet rs = null; try{ cs = (oracle.jdbc.CallableStatement)conn.prepareCall(sqlStr); cs.setLong(1,arg[0]); cs.setLong(2,arg[1]); cs.registerOutParameter(3,oracle.jdbc.OracleTypes.CURSOR); cs.execute(); rs = cs.getCursor(3); while(rs.next()){ //........... } rs.close(); cs.close(); }catch(Exception e){ System.out.println("produce error "); e.printStackTrace(); }
CallableStatement cs = null; cs = conn.prepareCall(sql); cs.setInt(1,maxrow); cs.setInt(2,minrow); cs.registerOutParameter(3,oracle.jdbc.OracleTypes.CURSOR); cs.execute(); rs = (ResultSet)cs.getObject(3);