Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

oracle thin driver scrollable resultset.absolute(1) is not returing the first row

 
Helen Ge
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am doing pagging with oracle scrollable resultset.

I have a query "select * from (complex subquery here) where rownum<=20" and I am using the oracle thin driver scrollable resultset and point to rs.absolute(1) to expect getting the 20 records. However the first record is always missing(only the 2nd-20th rows returned). If I changed the rs.absolute(1) to rs.beforeFirst(), then all the 20 records returned.


Can someone point to me what my problem could be? Why the absolute(1) not working correctly?

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helen,
After you call rs.absolute(1), are you calling rs.getXXX() before rs.next()? If so, it is going to the next row before retrieving the data from the first row.
 
Helen Ge
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne.

You are right. I overlooked the while(rs.next()) actually already moved cursor forward one position.

Now I changed to use do{....}while(rs.next()). and it works.

Thank you very much for the sharp eyes!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic