如何从plsql函数创建并返回游标?

如何从plsql函数创建并返回游标?,plsql,oracle11g,Plsql,Oracle11g,我创建了一个plsql函数,我想创建一个游标并从函数返回这个游标。然后我想在Java类中调用这个函数,并从游标中检索数据。注意:光标返回一行。 我写了这样的东西 CREATE OR REPLACE FUNCTION FUNCTION1 ( emp_id IN NUMBER)RETURN cursor AS cursor newCursor(e_id number) is select * from table1 where employee_id = e_id;

我创建了一个plsql函数,我想创建一个游标并从函数返回这个游标。然后我想在Java类中调用这个函数,并从游标中检索数据。注意:光标返回一行。 我写了这样的东西

CREATE OR REPLACE
FUNCTION FUNCTION1 ( emp_id IN NUMBER)RETURN cursor AS

  cursor newCursor(e_id number) is  
    select * from table1 where employee_id = e_id;        
    type refCursor is ref cursor;

  BEGIN

  open newCursor(emp_id);    
  loop
  exit when newCursor%notfound;   
    fetch newCursor into refCursor;  
  end loop;
  RETURN refCursor;

END FUNCTION1;

如果我想返回光标,我应该使用什么返回类型?

在以下函数之后对其进行建模

create or replace function getemps return sys_refcursor is
v_curs sys_refcursor;
begin
open v_curs for select ename from emp;
return v_curs;
end;
/

根据以下功能对其进行建模

create or replace function getemps return sys_refcursor is
v_curs sys_refcursor;
begin
open v_curs for select ename from emp;
return v_curs;
end;
/

sys_refcursor是oracle的通用隐式游标
改用显式游标

sys\u refcursor是oracle的通用隐式游标
改为使用EXPLICITE cursor

如果我想在这种情况下将参数传递给光标,我该如何做??如何在包中做?如果我想在这种情况下将参数传递给光标,我该如何做??如何在包中做?