How can I paginate a SOW Query?

Follow

Starting with AMPS 5.2, AMPS includes the skip_n option, which provides the ability to skip a set number of rows from a SOW query. Combined with the top_n and OrderBy options, this makes it easy to paginate a SOW query.

For example, if you have a set of messages like this:

orderId=204;date=2015-08-02;customer=John;...
orderId=194;date=2014-07-11;customer=David;...
orderId=72;date=2015-02-13;customer=Jill;...
orderId=102;date=2015-03-09;customer=Sue;...

You could split these into pages of 2 records (using 2 just to keep things short / simple) by submitting a query with OrderBy set to /orderId, the top_n=2 option, and a skip_n=x option. In this case, x is set to 2 * (the page number to retrieve - 1).

For example, to render the first page, the SOW query would have these modifiers:

OrderBy: /orderId
top_n=2,skip_n=0

To render the second page, the SOW query would include:

OrderBy: /orderId
top_n=2,skip_n=2

... and so on, throughout the results.

Keywords: ROWNUM, Skip / Take, OrderBy, Pagination, top_n, TopN, skip_n, SkipN

Have more questions? Submit a request

Comments

Powered by Zendesk