Home » SQL & PL/SQL » SQL & PL/SQL » problen in ref cursor
problen in ref cursor [message #443951] Thu, 18 February 2010 02:31 Go to next message
abes_nitya
Messages: 4
Registered: September 2006
Location: Noida
Junior Member
When I create following function returning ref cursor.
If I call this function from sql statement it is showing an error...
-- inconsistant datatype. expected number got cursor.

please tell me the solution....!

create or replace
function jarek_refcursor return sys_refcursor
is
c1 sys_refcursor;
begin
open c1 for select * from tab;
return c1;
end

select jarek_refcursor from dual
Re: problen in ref cursor [message #443953 is a reply to message #443951] Thu, 18 February 2010 02:41 Go to previous message
Michel Cadot
Messages: 63818
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why do you think it is a "Backup & Recovery" question?

SQL> create or replace
  2  function jarek_refcursor return sys_refcursor
  3  is
  4  c1 sys_refcursor;
  5  begin
  6  open c1 for select * from emp;
  7  return c1;
  8  end;
  9  /

Function created.

SQL> select jarek_refcursor from dual ;
JAREK_REFCURSOR
--------------------
CURSOR STATEMENT : 1

CURSOR STATEMENT : 1
     EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
---------- ---------- --------- ---------- ----------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-1980        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-1981       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-1981       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-1981       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-1981       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-1981       2850                    30
      7788 SCOTT      ANALYST         7566 19-APR-1987       3000                    20
      7839 KING       PRESIDENT            17-NOV-1981       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-1981       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-1987       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-1981        950                    30
      7902 FORD       ANALYST         7566 03-DEC-1981       3000                    20

12 rows selected.


1 row selected.

Which error?

Do as I did, copy and paste your SQL*Plus session.
And also ALWAYS post your Oracle version number (with 4 decimals).

Regards
Michel

[Updated on: Thu, 18 February 2010 02:42]

Report message to a moderator

Previous Topic: Not much memory left for Oracle Process
Next Topic: IIF and Oracle
Goto Forum:
  


Current Time: Fri Sep 30 22:45:29 CDT 2016

Total time taken to generate the page: 0.07051 seconds