Display REFCURSOR results through PL/SQL [message #267439] |
Thu, 13 September 2007 05:11  |
10guser
Messages: 16 Registered: September 2007
|
Junior Member |
|
|
Hi,
CREATE OR REPLACE PACKAGE try AS
TYPE REF_CUR IS REF CURSOR;
FUNCTION AVG(num1 in number, num2 in NUMBER) RETURN REF_CUR;
END try;
/
SQL>
DECLARE
emp_curvar try.ref_cur;
val SYS_REFCURSOR;
BEGIN
OPEN emp_curvar FOR SELECT try.avg(34,65) from dual;
Fetch emp_curvar into val;
dbms_output.put_line(val);
END;
SQL> /
dbms_output.put_line(val);
*
ERROR at line 7:
ORA-06550: line 7, column 7:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 7, column 7:
PL/SQL: Statement ignored
My question is how value of val(REF_CURSOR) be displayed here as
DBMS_OUTPUT cannot return datatype-REF_CURSOR
Any suggestions would be highly appreciated.
Many thanks
|
|
|
|
|
|
|
Re: Display REFCURSOR results through PL/SQL [message #267469 is a reply to message #267467] |
Thu, 13 September 2007 06:54   |
10guser
Messages: 16 Registered: September 2007
|
Junior Member |
|
|
Hi Michel
I want to return value of AVG in val via REF CURSOR.
When I run thru SQL it runs okay....
SQL> SELECT pkg_icm.func_get_average(34,65) from dual;
PKG_ICM.FUNC_GET_AVE
--------------------
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
AVERAGE
----------
49.5
but how would is display value 49.5 thru PL/SQL ?
Thanks
|
|
|
|
|
|
Re: Display REFCURSOR results through PL/SQL [message #267482 is a reply to message #267480] |
Thu, 13 September 2007 07:45   |
10guser
Messages: 16 Registered: September 2007
|
Junior Member |
|
|
Hi,
CREATE OR REPLACE PACKAGE try AS
TYPE REF_CUR IS REF CURSOR;
FUNCTION AVG(num1 in number, num2 in NUMBER) RETURN REF_CUR;
END try;
/
SQL>
DECLARE
emp_curvar try.ref_cur;
val SYS_REFCURSOR;
BEGIN
OPEN emp_curvar FOR SELECT try.avg(34,65) from dual;
Fetch emp_curvar into val;
dbms_output.put_line(val);
END;
SQL> /
dbms_output.put_line(val);
*
ERROR at line 7:
ORA-06550: line 7, column 7:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 7, column 7:
PL/SQL: Statement ignored
My question is how value of val(REF_CURSOR) be displayed here as
DBMS_OUTPUT cannot return datatype-REF_CURSOR
I'm opening the cursor and fetching it.
I'm not looping bcoz its just going to return single row.
Many thanks
|
|
|
|
|
|
|
|
|
Re: Display REFCURSOR results through PL/SQL [message #267582 is a reply to message #267581] |
Thu, 13 September 2007 14:28   |
10guser
Messages: 16 Registered: September 2007
|
Junior Member |
|
|
val is SYS_REFCURSOR
code is .....
CREATE OR REPLACE PACKAGE try AS
TYPE REF_CUR IS REF CURSOR;
FUNCTION AVG(num1 in number, num2 in NUMBER) RETURN REF_CUR;
END try;
DECLARE
emp_curvar try.ref_cur;
val SYS_REFCURSOR;
BEGIN
OPEN emp_curvar FOR SELECT try.avg(34,65) from dual;
Fetch emp_curvar into val;
dbms_output.put_line(val);
END;
|
|
|
|
|
|
|
|