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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Using Rownum and ROwid returns duplicate records

578402May 18 2007 — edited May 18 2007
Hi All,

We have implemented pagination as below using rowid and rownum

SELECT
id
FROM
emp
WHERE
(
ROWID IN
(
SELECT RID FROM (SELECT
ROWID RID,
ROWNUM RNUM
FROM
SELECT ID FROM emp
WHERE
((T_ID IN (200005,200229,200230,200249,200250,200049))) AND
(dte >= sysdate-90) AND
(LOWER(DESC) = LOWER ('A') AND
LOWER(NVL(FLAG,'0')) != LOWER ('3') AND
LOWER(MODDE) like LOWER ('%210%')) ORDER BY dte ASC ))
WHERE ROWNUM < 11) WHERE RNUM>= 1)) ORDER BY dte emp.ASC


But, we face that - the query inserts duplicate records in consecutive pages. For Eg:
1.if a,b,c,d,e - is returned for first iteration, then for the next iteration - f,g,h,a,y is returned.

Is it because that the Order by clause doesnt have a Unique key column.
Please help. or suggest how to efficietly implement pagination without performance hit
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2007
Added on May 18 2007
2 comments
568 views