简体   繁体   中英

Paginating result set in oracle database

我的事务处理服务以oracle db为后端,有很多客户将调用我们的服务来获取数据。当我们收到数据请求时,我们需要查询db,获取结果集并将其发送到分页中我不想查询。但是想知道到底发生了什么。说说如果结果集有20,000行,并且如果我们需要每页发送100个数据作为响应,那么我怎么能说还有剩余的数据集,在响应中,以便客户需要点击我们的服务才能获取下一页?。说响应是json格式。resposne格式应该是什么样??我是oracle新手。感谢您的帮助。

To select the data the paginated way, try

    select order_id, order_descr
  from (select order_id, order_descr, row_number() over(order by order_date desc) r
          from orders
          where customer_id = 123)
 where r between 1 and 101

to display order 1 upto 100 (first page) of customer_id 123.

If you receive at client side more than 100 rows of data then more data exists.

The inner select statement with order by clause is necessary.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM