Make query with offset and limit on openedge

302 Views Asked by At

can anyone explain me please the best way to make query in openedge progress (not using sql) to make pagination like. My idea is to make query with offset and fetch like normally I do when make a query in sql style... Like select * from table OFFSET 50 ROWS FETCH NEXT 10 Rows. Can anyone help me, please? Thanks in advance. CC

  1. I have not found anything to help me in Google searching so far...
1

There are 1 best solutions below

3
Mike Fechner On

There is no built in pagination in the ABL OPEN QUERY or FOR EACH statements. If you need pagination you need to iterate the query and handle it programmatically.

The ProDataset has pagination built in - I have posted a sample yesterday at https://community.progress.com/s/question/0D54Q0000A6Mg4QSQS/is-there-a-way-to-do-paged-loading-in-abl-

DEFINE QUERY qry FOR Customer SCROLLING.

DEFINE VARIABLE i AS INTEGER NO-UNDO.

/* first page */
OPEN QUERY qry FOR EACH Customer INDEXED-REPOSITION.
GET FIRST qry NO-LOCK .

DO WHILE NOT QUERY qry:QUERY-OFF-END:
    DISPLAY Customer.CustNum Customer.Name
        WITH DOWN FRAME frmCustomer .
    DOWN WITH FRAME frmCustomer .

    i = i + 1 .

    IF i >= 10 THEN
        LEAVE .

    GET NEXT qry NO-LOCK .
END.

/* second page */
PAUSE .
i = 0 .

OPEN QUERY qry FOR EACH Customer NO-LOCK INDEXED-REPOSITION.
REPOSITION qry TO ROW 11 .
GET NEXT qry NO-LOCK .

DO WHILE NOT QUERY qry:QUERY-OFF-END:
    DISPLAY Customer.CustNum Customer.Name
        WITH DOWN FRAME frmCustomer .
    DOWN WITH FRAME frmCustomer .

    i = i + 1 .

    IF i >= 10 THEN
        LEAVE .

    GET NEXT qry NO-LOCK .
END.