Hi.
I'm not sure what you mean by traverse. You don't have to use a loop if you don't want to, but if you want to process every row in a cursor this is the most sensible approach to take.
There is no way to jump straight to the end, or to a specific row of a cursor, unless you actually change the query driving the cursor, which is not what you want to do.
An approach that might help you is to use a BULK COLLECT into a PL/SQL table. This is a collection, like an array, which allows you to jump around to the first or last or any row you want. Like this:
SET SERVEROUTPUT ON
DECLARE
TYPE emp_tab IS TABLE OF emp%ROWTYPE;
t_tab emp_tab := emp_tab();
BEGIN
SELECT *
BULK COLLECT INTO t_tab
FROM emp;
DBMS_OUTPUT.put_line('Last ENAME : ' || t_tab(t_tab.last).ename);
DBMS_OUTPUT.put_line('First ENAME: ' || t_tab(t_tab.first).ename);
END;
/
You might want to read this also:
http://www.oracle-base.com/articles/9i/ ... sing9i.php
Be careful not to use this type of prcessing for everything. These collections are held in memory on the DB server so they are not suitable for massive queries unless you are happy to tie up lots of memory.
Cheers
Tim...