Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: beginner: on a related note....cursors

Re: beginner: on a related note....cursors

From: sybrandb <sybrandb_at_gmail.com>
Date: 10 Apr 2007 02:12:31 -0700
Message-ID: <1176196351.742765.64270@o5g2000hsb.googlegroups.com>


On Apr 10, 10:01 am, hasta..._at_hotmail.com wrote:
> On 10 avr, 08:54, "matt" <reflectio..._at_gmail.com> wrote:
>
>
>
>
>
> > I have put together the following plsql and can verify that it does
> > return the expected result..."the closest existing salary to a user
> > entered salary of 8000"
> > The problem i face with this having to make this a stored procedure or
> > function without whole-sale changes. Any ideas? The required use of
> > a cursor makes this especially challenging for me.
>
> > DECLARE
> > name empbb02.ename%TYPE;
> > salary empbb02.sal%TYPE;
> > TYPE cursor_var IS REF CURSOR;
> > myCursorVar cursor_var;
> > TargetSalary empbb02.sal%TYPE;
> > rk number(5);
>
> > BEGIN
>
> > OPEN myCursorVar FOR SELECT RANK()OVER(ORDER BY ABS(E.sal - 8000))AS
> > RNK, E.ename
> > , E.sal
> > FROM empbb02 E;
>
> > LOOP
> > FETCH myCursorVar INTO rk, name,salary;
> > EXIT WHEN myCursorVar%NOTFOUND OR rk ='2';
> > DBMS_OUTPUT.PUT_LINE(rk||' '||name||' '||salary);
> > END LOOP;
> > CLOSE myCursorVar;
> > END;
> > /
>
> Dear Matt, please allow me a few comments :
>
> 1) This group is more oriented toward oracle administration
> discussions. Questions like the above would be more on-topic
> in comp.databases.oracle.misc.
>
> 2) People posting here are experts (not me :-). They will gladly
> help, but they - rightly - require that documentation has been read
> and research has been performed before a question is asked.
>
> 3) One way to start with Oracle is to read the concept manual
> from top to bottom, and from there to move on to some other
> manuals - eg the PL/SQL User's Guide and Reference. The
> documentation is freely available athttp://tahiti.oracle.com/
>
> 4) A great resource to search for ishttp://asktom.oracle.com/
> eghttp://asktom.oracle.com/tkyte/ResultSets/index.html
>
> Hope it helps. Have a very nice day
>
> --- Raoul- Hide quoted text -
>
> - Show quoted text -

Please allow me to explain to you the division between the various groups in comp.databases.oracle

.server is geared at the RDBMS, and SQL
.tools is geared at Oracle frontends
.misc is geared at all non-Oracle products interfacing to Oracle.
.marketplace is for spam ;)
--
Sybrand Bakker
Senior Oracle DBA
Received on Tue Apr 10 2007 - 04:12:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US