i want to read first 5 records and want to skip the next 5 records and want to read another 5 records in a db2 table using cursor.? how do i do that

5 pts.
Tags:
DB2 query
i want to read first 5 records and want to skip the next 5 records and want to read another 5 records in a db2 table using cursor.? how do i do that
ASKED: July 24, 2009  5:35 PM
UPDATED: July 27, 2009  8:23 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

When I come across someone specifying “first” or “next” or “last” in a discussion of RDBMS rows, I must remind you that there is no logical sequence to any data stored in an RDBMS (DB2 or other).

So, with that knowledge, you must have an ORDER BY in your CURSOR. Only an ORDER BY (or something else to force a sort) will put rows into some guaranteed sequence.

And since an ORDER BY happens just before the data is returned to your application the only way to “skip” rows returned by the cursor is to FETCH 5 times without processing them.

This raises a question in my mind… why would you want to do this?

I have to believe that if you define your selection criteria better, you could develop a query that would return ONLY the rows you want. That is the proper method.

Steve

Discuss This Question:  

 
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

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