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
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
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:
To render the second page, the SOW query would include:
... and so on, throughout the results.
Prior to 5.2.3, pagination is only supported for a SOW query. Starting in 5.2.3, AMPS also provides support for paginated sow and subscribe. This provides paginated results during the query, and only provides messages to the subscription that would fall within the specified page of results. See the User Guide for more details.
Keywords: ROWNUM, Skip / Take, OrderBy, Pagination, top_n, TopN, skip_n, SkipN