Paging problems

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 02-Aug-2005 19:14:00   

Hi,

Does anyone have any idea what one does if a supplied page index is beyond the maximum page index of a result set?

The trouble is that you don't know whether the page index is valid until you're retrieved the result set.

Cheers,

I.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 02-Aug-2005 19:22:36   

You can try to determine the # of pages by executing a getscalar query first. Then, when you know that number, simply page through the real resultset. Or am I missing something?

Frans Bouma | Lead developer LLBLGen Pro
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 02-Aug-2005 20:01:46   

Thanks for your reply.

What if it was an extra active database and the count changed between looking it up specifically and getting the actual rows?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 02-Aug-2005 20:40:20   

Ian wrote:

Thanks for your reply.

What if it was an extra active database and the count changed between looking it up specifically and getting the actual rows?

You can never be sure about that, unless for each page you query the db for the actual # of pages. And even then, it can differ. The # of pages to browse through is an estimate. Even on Google it is. Often there are initially 5 pages, but when you're at page 2, there seem to be only 3 or so. As soon as the user starts the action of 'get me the XYZ rows for september' or something, the action starts, and the # of pages to browse through IMHO should be calculated then, as when the paging logic wasn't used (but all rows were read) the user would get that amount of pages of data as well.

Frans Bouma | Lead developer LLBLGen Pro