SOLVED: HOW TO RUN ROW PAGINATION ON ORACLE 11g AND 12c

·

1 min read

SOLVED: HOW TO RUN ROW PAGINATION ON ORACLE 11g AND 12c

Welcome to another new week, fellas.

I had an interesting conversation with my friend some weeks back and he reminisced on a project he worked on for a company.

He mentioned that they hit a bit of a snafu as they were unable to write the script that would fetch them the data for 500 customers on a single page. They were able to figure it out after weeks of trying different methods. I will be dropping the scripts I think they used vs my solution on both 11g and 12c for Row Pagination. It is worth knowing that oracle 12c has simplified pagination with limit and fetch clauses.

On 11g, this query will generate zero Rows.

select cust_name where rownum >400 and <900;

: No rows

VS

11g: This query will generate the desired result.

select cust_name from (select b.cust_name, rownum rn from (select cust_name from customer order by id) b where rownum<=900) where rownum >400;

12c: This query will generate the desired result.

select cust_name from customer limit 400 offset 500;

I hope this was helpful for you.

Please give this article all the likes you can give. You can also share your thoughts here.