Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: beginner: cursors
Other things you might want to consider are:
1. Using a FOR LOOP
2. If you're just want the first match (where there are equal ranks)
then using SELECT ... INTO and no LOOP.
3. Rather than bombing out of the loop when NOTFOUND or rk=2, restrict
the rk=2 condition in the actual select:
e.g. SELECT rnk,ename,sal FROM (SELECT RANK()OVER(ORDER BY ABS(E.sal -
8000)) AS RNK, E.ename, E.sal FROM empbb02 E ORDER BY rnk) WHERE rnk =
1;
4. Creating a function that accepts the salary as an input and returns
the refcursor, rather than outputting to dbms_output
Received on Tue Apr 10 2007 - 03:52:19 CDT
![]() |
![]() |