需求比较奇怪... 既然 "当我翻到第三页的时候,前面第一页的“我 22 小学”被删除" 那就没法做成通用的存储过程了.参考:create or replace package types as type rc is ref cursor; end;create or replace procedure QueryByPage ( TableName in varchar2; iMinVal in number; iMaxVal in number; p_cursor types.rc; ) is begin open p_cursor for ' select * from (select t1.*, rownum rnum ' || ' from (select * from ' || TableName ||') t1 ' || ' where rownum <= :iMax) where rnum >= :iMin ' using iMaxVal,iMinVal; exception when others then null; end; / --call it from sqlplus variable cur refcursor exec QueryByPage('Table1',1,100,:cur); print cur;
不太明白,怎么不见了?
你问的是什么?
我说的是,把前面的一条给删除掉了!
需求比较奇怪...
既然 "当我翻到第三页的时候,前面第一页的“我 22 小学”被删除"
那就没法做成通用的存储过程了.参考:create or replace package types
as type rc is ref cursor;
end;create or replace procedure QueryByPage
(
TableName in varchar2;
iMinVal in number;
iMaxVal in number;
p_cursor types.rc;
)
is
begin
open p_cursor for ' select * from (select t1.*, rownum rnum ' ||
' from (select * from ' || TableName ||') t1 ' ||
' where rownum <= :iMax) where rnum >= :iMin ' using iMaxVal,iMinVal; exception when others then
null;
end;
/
--call it from sqlplus
variable cur refcursor
exec QueryByPage('Table1',1,100,:cur);
print cur;