Stored Procedure refcursor of the returned result set in Oralce

Source: Internet
Author: User
Since Oracle stored procedures do not return values, all their return values are replaced by the out parameter, and the list is no exception. However, because it is a set, it cannot be used as a general

Since Oracle stored procedures do not return values, all their return values are replaced by the out parameter, and the list is no exception. However, because it is a set, it cannot be used as a general

Stored Procedure with returned values (list result set)
Case: Write a process, enter the Department number, and return the information of all employees of the Department.

The analysis of this question is as follows:
Since Oracle stored procedures do not return values, all their return values are replaced by the out parameter, and the list is no exception. However, because it is a set, general parameters cannot be used, you must use a package. Therefore, there are two parts:

1) create a package. As follows:

Create or replace package testpackage as type test_cursor is ref cursor;
End testpackage;

In this package, I defined a cursor type test_cursor.

The following is the write creation process.
Create or replace procedure chenchuang_pro
(ChenNo in number p_cursor out testpackage. test_cursor) is
Begin
Open p_cursor for select * from emp wheredeptno = chenNo;
End;

Ref cursor: cursor type

,

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.