ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORACLE中返回结果集示例

ORACLE中返回结果集示例

原创 Linux操作系统 作者:hxhy 时间:2019-06-17 17:27:06 0 删除 编辑

注意:此文档是本人写的


create or replace package test_pack as
type ref_cursor is ref cursor;
end;
/
create or replace procedure get_rest(n in number,rst out test_pack.ref_cursor)
as
begin
open rst for select deptno,dname,ename,sal
from (select dept.deptno,dname,ename,sal ,row_number() over(partition by dept.deptno
order by sal desc ) cnt from emp,dept where dept.deptno=emp.deptno)
where cnt<=n;
end;
/


create or replace function get_rest(n in number)
return test_pack.ref_cursor
as
v_rst test_pack.ref_cursor;
begin
open v_rst for select deptno,dname,ename,sal
from (select dept.deptno,dname,ename,sal ,row_number() over(partition by dept.deptno
order by sal desc ) cnt from emp,dept where dept.deptno=emp.deptno)
where cnt<=n;
return v_rst;
end;
/

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/50509/viewspace-174250/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2003-06-28

  • 博文量
    27
  • 访问量
    25525