Paging with Oracle and sql server and generic paging method

前端 未结 7 1106
予麋鹿
予麋鹿 2020-12-17 00:29

I want to implement paging in a gridview or in an html table which I will fill using ajax. How should I write queries to support paging? For example if pagesize is 20 and wh

7条回答
  •  余生分开走
    2020-12-17 01:10

    "Because...data can be change from other sessions." What do you want to happen for this ?

    For example, user gets the 'latest' ten rows at 10:30.

    At 10:31, 3 new rows are added (so those ten being view by the user are no longer the latest).

    At 10:32, the user requests then 'next' ten entries.

    Do you want that new set to include those three that have been bumped from 8/9/10 down to 11/12/13 ? If not, in Oracle you can select the data as it was at 10:30

    SELECT * FROM table_1 as of timestamp (timestamp '2009-01-29 10:30:00'); 
    

    You still need the row_number logic, eg

     select * from
        (SELECT a.*, row_number() over (order by hire_date) rn
        FROM hr.employees as of timestamp (timestamp '2009-01-29 10:30:00') a)
     where rn between 10 and 19
    

提交回复
热议问题