declare
page number(6);n number(6);begin
page:=2;
n:=10;
SELECT * FROM
     (
     SELECT A.*, rownum r
     FROM
          (
          SELECT *
          FROM sb_bb001010_mx01
          
          ) A
     WHERE rownum <= n*page
     ) B
WHERE r > (page-1)*n
end;

解决方案 »

  1.   

    select * from 
    (SELECT *,rownum rows
              FROM sb_bb001010_mx01 where rownum <= n*page) a
    where a.rows > (page-1)*n
      

  2.   

    不能在begin ... end 中间写SELECT语句。在ORACLE里跟MS SQL里不一样的
    你就直接拼起来写动态SQL语句执行吧。别写PL/SQL了。要不就用游标返回数据集,不过好象有点麻烦
      

  3.   

    SQL> create table test (id number);表被创建SQL> ed
    SQL> /PL/SQL 过程成功完成SQL> commit;提交完成SQL> select * from test;        ID
    ----------
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
            11
            12
            13
            14
            15
            16
            17
            18
            19
            20        ID
    ----------
            21
            22
            23
            24
            25
            26
            27
            28
            29
            30
            31
            32
            33
            34
            35
            36
            37
            38
            39
            40
            41        ID
    ----------
            42
            43
            44
            45
            46
            4747 行 已选择SQL> select * from
      2  (SELECT test.*,rownum rn
      3  FROM test )
      4  where rn > 9*&n and rn <= &n*10
      5  / 
    (n=3)
            ID         RN
    ---------- ----------
            28         28
            29         29
            30         30SQL> /
    (n=4)
            ID         RN
    ---------- ----------
            37         37
            38         38
            39         39
            40         40
      

  4.   

    难到就不能直接在PL/SQl的SQLwindow里执行成功吗
      

  5.   

    SELECT * rownum r   FROM A where rownum not on (select rownum from A )and rownum >(p-1)*n