Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PAGINATION and REF CURSOR

ZaboApr 8 2009 — edited Apr 8 2009
Hello,

When I want to do some pagination,
1/ I need to do a count(*) to know how many rows I have, so that on my php page I can compute the number of pages I have.
select count(*) from (my query).
2/ I write a second query to do the pagination.
SELECT * FROM (SELECT a.*, rownum rn FROM (my query including ORDER BY) a WHERE rownum < p_max ) WHERE rn > p_min

The problem with this solution is that I have to write twice my query and when one is changing I also have to change the second.

Is there a solution based on REF CURSOR for my query and then doing a count and the pagination on the REF CURSOR.

Does anyone know, if it is possible to do something like this ?

Edited by: Zabo on Apr 8, 2009 6:38 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2009
Added on Apr 8 2009
16 comments
4,123 views