AS/400 and DB2: Pagination query

351275 pts.
Tags:
AS/400
IBM DB2
PHP
I'm currently working on a project in which I'm trying to create PHP web-based paging for our tables that have over a million rows. I've figured out that I have three options:

  • Retrieve all rows in resultset (Not possible due to the size)
  • Retrieve 1,000 rows, put in temporary table and create an iterator for it and page through it
  • Run a query each time if someone goes page forward or backward

I'm working with option #3. I have the first page showing up as "select * from account order by acct fetch first 10 rows only" Page next "select * from account where acct>(last record) order by acct fetch first 10 only" page last record "select * from account where acct=(select max(acct) from account)"

The problem is that it keeps showing the previous page! Any help would be appreciated.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    What is your DB2 release? If you have any current release, the ROW_NUMBER() function would almost certainly be a better choice. -- Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following