Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> how to pass a cursor to a function?

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: how to pass a cursor to a function?
 ankur  Posted: Aug 30, 2007 07:27:20 AM

 Total Post: 59
 Joined: Nov, 2006






 how to pass a variable containing more that 1 value to a function?

I have this variable created using IS TABLE OF keyword.
i fetched some records into the variable using BULK COLLECT INTO
now i want to pass this to a function....
can anybody tell me the procedure to do it.........

 Nehru
Posted: Aug 31, 2007 12:08:27 AM  

 Total Post: 46
 Joined: Jul, 2007






 
Hi

You can pass a CURSOR to the Function/Procedure as following,

CREATE OR REPLACE PACKAGE <Package Name> AS

TYPE cursor_type IS REF CURSOR;-- Declare a Reference Cursor here in pkg.
PROCEDURE <procedure Name>(
var1 IN VARCHAR2,
cur_OUT IN OUT cursor_type);-- Pass it as IN OUT Parameter
FUNCTION <Function Name>(
<parameters>,
cur_OUT IN OUT cursor_type) RETURN <type>;

END;

CREATE OR REPLACE PACKAGE BODY <Package Name> AS

PROCEDURE <procedure Name>(
var1 IN VARCHAR2,
cur_OUT IN OUT cursor_type) AS

BEGIN

OPEN cur_OUT FOR
<your statements are here>;
END;
FUNCTION <Function Name>(
<parameters>,
cur_OUT IN OUT cursor_type) RETURN <type> AS
BEGIN

OPEN cur_OUT FOR
<your statements are here>;
RETURN <variable>;
END;

END;

Pass a REFERENCE CURSOR through Package you can use this in either in Function or Procedure.
I Think this will be HELP For your requirement,
If not let me Know then i will try again,

Any one Let me Know if am wrong.

Take Care,


Bye
Nehru

 ankur
Posted: Aug 31, 2007 02:47:33 AM  

 Total Post: 59
 Joined: Nov, 2006






 
thats fine.thanks

tell me one more thing ...

can we use the same as a normal cursor inside the function ?


 Nehru
Posted: Aug 31, 2007 02:51:42 AM  

 Total Post: 46
 Joined: Jul, 2007






 
Hi,

Are you under stand my post? am not formatted perfectly!
YES, You can use Normal Cursor Inside Function and also Procedures,

Any one let me know if am wrong.

Take care,
Bye
Nehru

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar357
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software