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

Re: Cursor help?

From: shakespeare <whatsin_at_xs4all.nl>
Date: Thu, 15 Nov 2007 20:52:01 +0100
Message-ID: <473ca363$0$228$e4fe514c@news.xs4all.nl>

"CK" <c_kettenbach_at_hotmail.com> schreef in bericht news:lj1%i.59735$RX.10419_at_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
>

Maybe you should not put the alias in (double) quotes, but  SELECT first_name, last_name ,count(*) sections

Shakespeare Received on Thu Nov 15 2007 - 13:52:01 CST

Original text of this message

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