请教各位 我写了一个分页的存储过程 如下 
 create or replace procedure PP(currpage in number,pagesize in number)
  as
  begin
 select * from (select rownum as rid,emp.* from emp where rownum<=currpage*pagesize)t where t.rid>(currpage-1)*pagesize;
 end PP;
过程可以创建 但在pl/sql developer 中查看到的这个过程上图标上有一个红叉 而且这个过程也无法被调用。
请教各位高手了 谢谢!

解决方案 »

  1.   

    存储过程中不能直接使用select,要用游标返回,或者游标fetch到变量
    参考:create or replace procedure proc_sel_chapter_page(
    in_series_id dat_ct_chapter.series_id%TYPE,
    in_page_size number,
    in_start_page number,
    out_cr_chapter OUT SYS_REFCURSOR
    )
    AS 
    begin
    open out_cr_chapter for
    select t.chapter_id,
    t.series_id,
    t.chapter_no,
    t.resolution,
    t.gold_coins,
    t.discount,
    t.file_path,
    t.status
    from (
    select row_number() over(order by resolution desc,chapter_no desc) rn,
    chapter_id,
    series_id,
    chapter_no,
    resolution,
    gold_coins,
    discount,
    file_path,
    status
    from dat_ct_chapter
    where series_id = in_series_id
    ) t
    where t.rn > in_page_size * (in_start_page - 1)
    and t.rn <= in_page_size * in_start_page; Exception when others then
    raise;
    end proc_sel_chapter_page;
    /