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 -> Cursor help?

Cursor help?

From: CK <c_kettenbach_at_hotmail.com>
Date: Thu, 15 Nov 2007 19:43:13 GMT
Message-ID: <lj1%i.59735$RX.10419@newssvr11.news.prodigy.net>


Oracle newbie question. I have a cursor with a group by clause. I can not get the column alias to print. It says "sections" need to be defined. Also I want this to only run against the first ten rows in the instructor table. I tried it this way and it doesn't work. Any dieas?

SET SERVEROUTPUT ON;
DECLARE
   CURSOR c_instructor_info IS

     SELECT first_name, last_name ,count(*) "sections"
     FROM instructor i INNER JOIN section s ON i.instructor_id = 
s.instructor_id
     WHERE rownum <= 10
     GROUP BY first_name, last_name;
     rv_instructor c_instructor_info%ROWTYPE;
BEGIN
   OPEN c_instructor_info;
   LOOP
    FETCH c_instructor_info INTO rv_instructor;     EXIT WHEN c_instructor_info%NOTFOUND;     DBMS_OUTPUT.PUT_LINE('Instructor: '||rv_instructor.first_name||' '||rv_instructor.last_name||', teaches '||rv_instructor.sections||' sections.');

   END LOOP;
   CLOSE c_instructor_info;
END;
/

Thanks for any help.
Cheers,
~ck Received on Thu Nov 15 2007 - 13:43:13 CST

Original text of this message

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