Oracle cursor type as input and output parameters

Source: Internet
Author: User
Tags oracle cursor

Oracle cursor type as input and output parameters:

-- Cursor type input parameter
DECLARE
/* CURSOR cur_ttt IS
SELECT 1 a FROM dual ;*/

TYPE typ_cur is ref cursor;
Val_cur typ_cur;

PROCEDURE temp_sp1 (x_cur OUT typ_cur) IS
BEGIN
OPEN x_cur for select 1 a FROM dual union all select 2 FROM dual;
END;

PROCEDURE temp_sp2 (p_cur IN typ_cur) IS
I NUMBER;
BEGIN
LOOP
FETCH p_cur INTO I;
Exit when p_cur % NOTFOUND;
Dbms_output.put_line (I );
End loop;
CLOSE p_cur;
END;
BEGIN
Temp_sp1 (val_cur );
Temp_sp2 (val_cur );

OPEN val_cur for select 3 a FROM dual union all select 4 FROM dual;
Temp_sp2 (val_cur );
END;

Related Article

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.