我创建了一个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;
Run Code Online (Sandbox Code Playgroud)
如果我想返回游标,我应该使用什么返回类型?
在以下功能工作之后对其进行建模
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;
/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13969 次 |
| 最近记录: |