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 10 Exceptions

1)Create the following script. For each section determine the number of students registered. If this number is equal to or greater than 15, raise the user-defined exception e_too_many_students and display the error message. Otherwise, display how many students are in a section. Make sure that your program is able to process all sections.
A1: Answer: Your answer should look similar to the following:
 SET SERVEROUTPUT ON SIZE 5000 DECLARE CURSOR section_cur IS SELECT section_id FROM section; v_total NUMBER; e_too_many_students EXCEPTION; BEGIN FOR section_rec in section_cur LOOP BEGIN -- calculate number of students enrolled SELECT COUNT(*) INTO v_total FROM enrollment WHERE section_id = section_rec.section_id; IF v_total ...

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