5 pts.
 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
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

Software/Hardware used:
ASKED: July 24, 2009  5:35 PM
UPDATED: July 27, 2009  8:23 PM

Answer Wiki:
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
Last Wiki Answer Submitted:  July 27, 2009  8:23 pm  by  Meandyou   5,205 pts.
All Answer Wiki Contributors:  Meandyou   5,205 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _