Although sanjay's procedure will give you the count you need, it probably isn't as effecient as you may think:
1. It uses a scrollable resultset which by design are slower than non-scrollable
2. From what I've read, the getLast() method just loops through the recordset to the last record anyways...and then rs.first()/rs.beforeFirst() loops back to the beginning.
In my experience I have found that using the "select count(*) from emp where..." before I execute "select empno, name...from emp where..." is more efficient especially for larger resultsets.
I did some
testing using both methods and my results were:
- Using "select count (*)" as described above - 200 to 300 milliseconds to execute in 10 trials
- Using the getRow() technique as described by sanjay - 500 to 600 milliseconds to execute in 10 trials
I just thought I would test this because I have never seen test results comparing the 2 techniques. Anyways, you can run your own tests if you like,
Jamie