oracle存储过程怎么返回结果集
createorreplacepackagemypageistypecursor_empisrefcursor;endmypage;-------------------...
create or replace package mypage
is
type cursor_emp is ref cursor;
end mypage;
------------------------
create or replace procedure emp_pro(tableName varchar2,pageCount number,pageSize number,
allSize out number,allPage out number,mycursor out mypage.cursor_emp)
is
Sql_s varchar2(1000);
Sql_count varchar2(1000);
startSize number:=pageCount*pageSize-pageSize+1;
endSize number:=pageCount*pageSize;
begin
Sql_s:='select * from
(select t1.*,rownum rn from '||tableName||' t1 where rownum <= '||endSize||') where rn >= '||startSize;
open mycursor for Sql_s;
Sql_count:='select count(*) from emp';
execute immediate Sql_count into allSize;
if mod(allSize,pageSize)=0 then
allPage:=allSize/pageSize;
else
allPage:=allSize/pageSize+1;
end if;
end;
用什么方法返回值,具体怎么操作,谢谢!! 展开
is
type cursor_emp is ref cursor;
end mypage;
------------------------
create or replace procedure emp_pro(tableName varchar2,pageCount number,pageSize number,
allSize out number,allPage out number,mycursor out mypage.cursor_emp)
is
Sql_s varchar2(1000);
Sql_count varchar2(1000);
startSize number:=pageCount*pageSize-pageSize+1;
endSize number:=pageCount*pageSize;
begin
Sql_s:='select * from
(select t1.*,rownum rn from '||tableName||' t1 where rownum <= '||endSize||') where rn >= '||startSize;
open mycursor for Sql_s;
Sql_count:='select count(*) from emp';
execute immediate Sql_count into allSize;
if mod(allSize,pageSize)=0 then
allPage:=allSize/pageSize;
else
allPage:=allSize/pageSize+1;
end if;
end;
用什么方法返回值,具体怎么操作,谢谢!! 展开
2个回答
展开全部
看你用什么语言,你的写法没有问题,一般就是用dataset接受返回的cursor就可以了。
更多追问追答
追问
就直接用plsql返回
追答
例子如下:
CREATE OR REPLACE FUNCTION MY_FUNCTION
RETURN SYS_REFCURSOR
AS
MY_CURSOR SYS_REFCURSOR;
BEGIN
OPEN MY_CURSOR FOR SELECT * FROM MY_TABLE;
RETURN MY_CURSOR;
END MY_FUNCTION;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询