Anybody know how make a good paging in db2?
Usually i retrieve all data from db2 and got the resultset object within a conditional from query like :
sql = "SELECT * from MSEmployee where Name like '%" + condition + "'%"
I always take 10 record for one page.
after that i got ResutlSet object and in this resultset i process to get data from it start and end with :
ResultSet rs = conn.createStatement(sql);
So if i use this mehtod from resultset , the pointer will point to that record position within start and take 10 data.
My Problem is i take all data in database and can make a traffic network. so if i have a million data , but i just want to display 10 data is make a not efficient for db2 and traffic. So anybody know how can i select 10 data directly from db2 and not processed in resultset?
Originally posted by cchattoraj
fetch first 10 rows only
Thanks for your answer, but if i use your statement, i' m just always got first 10 records. But if i have 30 records, and i make paging is mean that i have 3 pages for each page contains record. Now, the problem is how can i know next page with next record within conditional i given?
i have 30 records, and page 1 is contain first 10 record, and page 2 contain 11 - 20 record, and page 3 contain 21 - 30 record. i cannot trace next record to display next page. Maybe you have another solution again....thanks