嗨,大家好,我正在研究一個存儲過程,但我被困在如何輸出下面的光標。我希望它能夠採取任何課程,然後吐出點數,課程編號和課程描述。這是我到目前爲止有:當我使用存儲過程傳入字符串時,如何輸出遊標?
EXEC STUDENT_COUNT_COURSE('CS 101');
CALLS
CREATE OR REPLACE PROCEDURE STUDENT_COUNT_COURSE (p_CrsNum IN COURSE.COURSENUM%TYPE)
IS
cursor cursor1 IS
SELECT CourseDesc.courseNum, CourseDesc.courseDesc, COUNT(DISTINCT Student.studentID) as "Count",
FROM Course INNER JOIN
CourseDesc ON Course.courseNum = CourseDesc.courseNum INNER JOIN
Grades ON Course.courseID = Grades.courseID INNER JOIN
Student ON Grades.studentID = Student.studentID
WHERE (CourseDesc.courseNum = p_CrsNum)
GROUP BY CourseDesc.courseNum, CourseDesc.courseDesc;
begin
for c in cursor1
loop
dbms_output.putline('There are COUNT students in' || c.courseNum ||', '|| c.dourseDesc);
//still working on count...
end loop;
end;
嘿,我需要它在存儲過程中。我已經更新了一下我的代碼。儘管如此,它還是拋出了錯誤。 – OneSneakyMofo 2010-11-28 00:40:55