O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9 Introduction to Cursors

1)Write a nested cursor where the parent cursor calls information about each section of a course. The child cursor counts the enrollment. The only output is one line for each course with the Course Name and Section Number and the total enrollment.
A1: Answer: Your answer should look similar to the following:
 SET SERVEROUTPUT ON DECLARE CURSOR c_course IS SELECT course_no, description FROM course WHERE course_no < 120; CURSOR c_enrollment(p_course_no IN course.course_no%TYPE) IS SELECT s.section_no section_no, count(*) count FROM section s, enrollment e WHERE s.course_no = p_course_no AND s.section_id = e.section_id GROUP BY s.section_no; BEGIN FOR r_course IN c_course LOOP DBMS_OUTPUT.PUT_LINE (r_course.course_no||' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required