REPOSITION-TO-ROWID + BREAK BY

Posted by Jens Dahlin on 09-May-2018 06:26

I have a query where I do:

PRESELECT EACH table NO-LOCK WHERE <where-clauses> BREAK BY field1 BY field2 BY field 3

The 25 first-of(field2) of the table are copied to a temp-table. The temp-table is returned to a gui. 

Now I want to add "pagination" for loading of more results to tried adding each records rowid to the temp-table and then utilize REPOSITION-TO-ROWID to get the query started at another record. This doesn't seem  to work - the same data is always returned. I've checked error-status, num-messages etc without any hints. 

I've used REPOSITION-TO-ROWID without BREAK BYs successfully before. Is it just not working with break by clauses or am I doing some other error here?

11.6 on Ubuntu

"Complete" code:

DEFINE QUERY qCache FOR <tablename> SCROLLING CACHE 50 RCODE-INFORMATION.

hQuery = QUERY qCache:HANDLE.


cQuery = "PRESELECT EACH <tablename> NO-LOCK WHERE " 
         + cCacheWhere 
         + " " + <lots-of-where-clauses>"
         + " " + "BREAK BY <tablename>.<field1> BY <tablename>.<field2> BY <tablename>.<field3>".

hQuery:QUERY-PREPARE(cQuery) NO-ERROR.
hQuery:QUERY-OPEN().

/* This is where I hoped to jump forward */ IF <rowid-variable> <> ? THEN hQuery:REPOSITION-TO-ROWID(<rowid-variable>) NO-ERROR. hQuery:GET-NEXT(). DO WHILE AVAILABLE <tableName>: IF hQuery:FIRST-OF("<tablename>.<field2>") THEN DO: CREATE <temptable>. BUFFER-COPY <tablename> TO <temptable> ASSIGN <temptable>.rwid = ROWID(<tablename>). iNumResult = iNumResult + 1. IF iNumResult >= 25 THEN LEAVE createResult. END. END.

All Replies

Posted by Stefan Drissen on 09-May-2018 08:02

complete /working/ example at:

abldojo.services.progress.com:443/

maybe you can expand your non-working to a complete working example? :-)

Posted by Jens Dahlin on 10-May-2018 06:08

After posting I made a clean example with a static query and it obviously works great. Away from work a couple of days but will go over everything once more when back.

This thread is closed