Oracle returns multiple result sets

Source: Internet
Author: User


Oracle returned multi-result set www.2cto.com Oracle stored procedure: create or replace procedure P_Sel_TopCount2 (in_top in number, out_count out number, cur_out_1 out sys_refcursor, cur_out_2 out sys_refcursor) is -- queries the data of the specified number of records, returns the total number of records, and returns the beginSELECT COUNT (*) into out_count FROM userinfo for multiple datasets; open cur_out_1 for SELECT * FROM userinfo where id <in_top; open cur_out_2 for SELECT * FROM userinfo where id <5; end P_Sel_TopCount2; www. 2cto.com Java calls to write a Java Class. public void openCursor () {Connection conn = null; ResultSet rs = null; CallableStatement stmt = null; String SQL = "{? = Call PKG_HOTLINE.getHotline ()} "; try {conn = getConnection (); stmt = conn. prepareCall (SQL); stmt. registerOutParameter (1, OracleTypes. CURSOR); stmt. registerOutParameter (2, OracleTypes. CURSOR); stmt.exe cute (); rs = (OracleCallableStatement) stmt ). getCursor (1); while (rs. next () {String country = rs. getString (1); String pno = rs. getString (2); System. out. println ("country:" + country + "| pno:" + pno);} www.2cto.com rs = (OracleCallableStatement) stmt ). getCursor (2); while (rs. next () {String country = rs. getString (1); String pno = rs. getString (2); System. out. println ("country:" + country + "| pno:" + pno) ;}} catch (Exception ex) {ex. printStackTrace () ;}finally {closeConnection (conn, rs, stmt) ;}} author kavy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.