简体   繁体   中英

Pagination in the AS400 SQL

I'm trying to do the pagination for the as400 table which is of version 6 and release 1

I'm using this query:

select * from AJSTYLES91.CLIENT 
ORDER BY CNUM
LIMIT 2 [OFFSET 2];

but is not working so can any one suggest me the proper query to use please!!!

I think declare global temporary table works in v6r1 . You can select all of your rows into a temporary table.

declare global temporary table orders as ( 
/* open orders */ 
select    a.orhordnum ordnum, a.orhshpnam shipname 
from      dwhpf30c a
where     a.orhcmp = 'N'
order by  a.orhshpnam 
 ) with data with replace  

then use rrn on that resulting table to calculate the page number and select on that page.

select     a.ordnum, a.shipname, rrn(a),              
           decimal( (rrn(a) -1) / 30,5,0) + 1 pageNum 
from       qtemp/orders a                             
where       decimal( (rrn(a) -1) / 30,5,0) + 1 = 5    

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