10.5. Package Body

The following is the body for the student's package. It includes just procedure code for the insert and a select for a student count.

This code could be enhanced with error handling logic; for example, it should include exception-handling logic for the case where the V_STATUS parameter violates the CHECK constraint (refer to pp. 103–104 for CHECK constraint exception handling.)

 CREATE OR REPLACE PACKAGE BODY students_pkg IS PROCEDURE add_student (v_student_name IN students.student_name%TYPE, v_college_major IN students.college_major%TYPE, v_status IN students.status%TYPE, v_state IN students.state%TYPE DEFAULT NULL, v_license_no IN students.license_no%TYPE DEFAULT NULL) IS BEGIN INSERT INTO students VALUES ('A'||students_pk_seq.NEXTVAL, ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.