I assume you saw this paging blog post ?
To answer your question, if we look at the code for the Sql class in Groovy, we will see that the code for rows(String,int,int)
calls rows(String,int,int,null)
And the code for this:
AbstractQueryCommand command = createQueryCommand(sql); ResultSet rs = null; try { rs = command.execute(); List<GroovyRowResult> result = asList(sql, rs, offset, maxRows, metaClosure); rs = null; return result; } finally { command.closeResources(rs); }
So, as you can see, it gets the full ResultSet
, then performs the steps inside the asList
method, populating the List<GroovyRowResult>
with the requested results.
Edit (after editing the question)
As I said in my comment below, I think you will need to write your own search query for the specific database that you are using ... For example, with MySQL , your previous query can be changed to:
def result = sql.rows( "SELECT * FROM table LIMIT ${Sql.expand x}, 1000" )
Other databases will have different methods for this kind of thing ... I do not believe that there is a standard implementation
source share