oracle 存储过程返回多个行代码实例

create   or   replace   procedure  s_get_all_point
(
   ref_cursor out sys_refcursor 
)
as
begin
  
open  ref_cursor  for
     
select   *   from  gwxx_t;
end ;


  try  {
          DriverManager.registerDriver (
new  oracle.jdbc.OracleDriver());
          Connection conn 
=  DriverManager.getConnection( " jdbc:oracle:thin:@localhost:1521:orcl " " @@@@ " "@@@@ " );

       
//    CallableStatement stmt = conn.prepareCall("BEGIN  s_get_all_point(?); END;");
          CallableStatement stmt  =  conn.prepareCall( " { call s_get_all_point(?) } " );////这名执行速度要快点

          stmt.registerOutParameter(
1 ,  oracle.jdbc.OracleTypes.CURSOR);  // REF CURSOR(OracleTypes.CURSOR==-10)
          stmt.execute();
          ResultSet rs 
=  (ResultSet) stmt.getObject( 1 );
          
while  (rs.next()) {
            System.out.println(rs.getString(
" gwbh " ));
          }
          rs.close();
          rs 
=   null ;
          stmt.close();
          stmt 
=   null ;
          conn.close();
          conn 
=   null ;
        }
        
catch  (SQLException e) {
          System.out.println(e.getLocalizedMessage());
        }



天苍苍,野茫茫,风吹草底见牛羊

你可能感兴趣的:(oracle 存储过程返回多个行代码实例)