Oracle 10g Release2 new functionality ref Cursor

Source: Internet
Author: User
Tags oracle database

REF cursor is the reference of the result set that we define on the server side. When we open a REF cursor, no data is returned to the client, instead, the address of the data on the server will be returned to the client. This allows the user to decide at what time and in that way to fetch the data through REF CURSOR.

In previous versions of Odp.net, we could fetch data through REF CURSOR, but we could not pass REF CURSOR as an input parameter to pl/sql stored procedures and stored functions. However, in Oracle Database 10g Release2, we can simply pass REF CURSOR as input parameter to pl/sql stored procedures and stored functions. This is a new feature of Oracle Database 10g Release2.

We'll introduce you to this new feature in a routine way.

Preparing the Database

We're going to generate a table and a package in the database, and we'll use that in the next example.

Please log in to the database with an HR user and run the following script.
create table processing_result
(
 status varchar2(64)
);
create or replace package cursor_in_out as
type emp_cur_type is ref cursor return employees%rowtype;
procedure process_cursor(p_cursor in emp_cur_type);
end;
/
create or replace package body cursor_in_out as
procedure process_cursor(p_cursor in emp_cur_type) is
employee employees%rowtype;
begin
 loop
  fetch p_cursor into employee;
  exit when p_cursor%notfound;
  insert into processing_result
  values('Processed employee #' ||
  employee.employee_id || ': ' ||
  employee.first_name || ' ' ||
  employee.last_name);
 end loop;
end;
end;
/

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.