Oracle-plsql stored procedure cursor when the parameter is

Source: Internet
Author: User
Tags dname

Baotou:

Create or Replace package Produrececursordata is

Type curtype is REF CURSOR;
Type Type_record is record
(
Deptno Number (2),
Dname VARCHAR2 (14),
Loc VARCHAR2 (13)
);
PROCEDURE Procedure1 (cur out curtype);

End Produrececursordata;


Inclusion

Create or Replace package body Produrececursordata is

PROCEDURE Procedure1 (cur out curtype)
As
Begin
Open cur for select * from DEPT;
End

End Produrececursordata;


Test:

Sql> select * from DEPT;

DEPTNO dname LOC
------ -------------- -------------
Ten ACCOUNTING NEW YORK
DALLAS
SALES CHICAGO
OPERATIONS BOSTON

Sql> set Serveroutput on
Sql> Declare
2 Curoutarg Produrececursordata.curtype;
3 Rec_arg Produrececursordata.type_record;
4 begin
5 dbms_output.put_line ('------------------------');
6 Produrececursordata.procedure1 (CUROUTARG);
7 loop
8 Fetch curoutarg into Rec_arg;
9 Exit when Curoutarg%notfound;
10 Dbms_output.put_line (rec_arg.deptno| | ' ' | | rec_arg.dname| | ' ' | | REC_ARG.LOC);
one end loop;
The end;
13/
------------------------
Ten ACCOUNTING NEW YORK
DALLAS
SALES CHICAGO
OPERATIONS BOSTON
PL/SQL procedure successfully completed

Record the results of the practice, hahaha.

Oracle-plsql stored procedure cursor when the parameter is

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.