467,107 Members | 1,239 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,107 developers. It's quick & easy.

give me idea for this procedure

I want the criteria like this.

I have 10k of rows in my table and i have to fetch first 200 rows . And
next time when i execute the same query it should fetch next 200 rows
and that should be continued .For that is there any query for my
requirement or I have to write a dynamic sql procedure for this .

In Oracle using rowid we can get the records dynamically where as in
DB2 is the facility is there or not ?
Give some guidance regarding my requirement.

Feb 28 '06 #1
  • viewed: 948
Share:
1 Reply
narayana wrote:
I want the criteria like this.

I have 10k of rows in my table and i have to fetch first 200 rows . And
next time when i execute the same query it should fetch next 200 rows
and that should be continued .For that is there any query for my
requirement or I have to write a dynamic sql procedure for this .

In Oracle using rowid we can get the records dynamically where as in
DB2 is the facility is there or not ?
Give some guidance regarding my requirement.

Do you have a single column key?
E.g. you can do:
SELECT pk, data FROM T WHERE pk > ? ORDER BY pk FETCH FIRST 100 ROWS

For the first call use e.g. a negative empid (a value out of bound).
Then for each subsequent select you use the last pk you retrieved before
a input.

If that's not possible do this:

SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY whatever) AS rn, t.*
FROM T) AS X WHERE rn BETWEEN ? AND ?

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Vlad Olevsky | last post: by
1 post views Thread by narayana | last post: by
32 posts views Thread by Matias Jansson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.