在 ms sql中 可以有
create procedure test
as
select *  from t1;
select * from t2;
/*****/
ado :while(!rs.eof){
  rs("dddd")
  rs.movenext
}
rs.next
.....
但是在oracle中怎么返回多个记录机
并且在java中读取他们呢?

解决方案 »

  1.   

    create procedure list_early_deaths () return refcursor as 
    declare
        toesup refcursor;
    begin
        open toesup for
            SELECT *
            FROM emp;
        return toesup;
    end;下面是调用该存储过程的Java方法,将结果输出到PrintWriter:static void sendEarlyDeaths(PrintWriter out)
    {
        Connection con = null;
        CallableStatement toesUp = null;
        try
        {
            con = ConnectionPool.getConnection();        // PostgreSQL needs a transaction to do this...
            con.setAutoCommit(false);        // Setup the call.
            CallableStatement toesUp
                = connection.prepareCall("{ ? = call list_early_deaths () }");
            toesUp.registerOutParameter(1, Types.OTHER);
            getResults.execute();        ResultSet rs = (ResultSet) getResults.getObject(1);
            while (rs.next())
            {
                String name = rs.getString(1);
                int age = rs.getInt(2);
                out.println(name + " was " + age + " years old.");
            }
            rs.close();
        }
        catch (SQLException e)
        {
            // We should protect these calls.
            toesUp.close();
            con.close();
        }
    }
      

  2.   

    楼上的,假如是多个记录集行不行呢?
    ms  sql   可以  在存储过程里面
    运行多个select 语句
    ado 里面有
    resultSet::nextResultSet但是 jdbc 好像没有这个功能
      

  3.   

    还是用cursor,
    create procedure list_early_deaths (ref1 out refcursor1,ref2 out refcursor2)