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 |
Send this thread to your friend |
|
|
|
|
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 Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Vinoth Kumar | 357 |
| Gopu Gopi | 340 |
| Gitesh Trivedi | 322 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|