SQL pagination support
Db2 12 introduces SQL syntax that enables dividing a query result table into separate pieces, so that, for example, mobile and web applications can present a subset of the rows of the result table at a time.
-
With the growth of web and mobile applications, application developers are looking for more efficient ways to develop good-performing applications. Db2 12 introduces the OFFSET clause to define the number of rows to skip from the beginning of the query result table:
SELECT * FROM TAB OFFSET 10 ROWS FETCH FIRST 10 ROWS ONLY;
-
Also available with Db2 12 is data-dependent pagination, which uses row value expressions in a basic predicate, which enables an application to access part of a Db2 result table based on a logical key value:
WHERE (LASTNAME, FIRSTNAME) > ('SMITH', 'JOHN')
Prior to Db2 12, such a statement had to be coded as:
WHERE (LASTNAME = 'SMITH' AND FIRSTNAME > 'JOHN') OR (LASTNAME > 'SMITH')