Chapter 7 Error Handling and Built-In Exceptions

1)Create the following script: Check to see whether there is a record in the STUDENT table for a given student ID. If there is no record for the given student ID, insert a record into the STUDENT table for the given student ID.
A1: Answer: Your answer should look similar to the following:
 SET SERVEROUTPUT ON DECLARE v_student_id NUMBER := &sv_student_id; v_first_name VARCHAR2(30) := '&sv_first_name'; v_last_name VARCHAR2(30) := '&sv_last_name'; v_zip CHAR(5) := '&sv_zip'; v_name VARCHAR2(50); BEGIN SELECT first_name||' '||last_name INTO v_name FROM student WHERE student_id = v_student_id; DBMS_OUTPUT.PUT_LINE ('Student '||v_name|| ' is a valid student'); EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE ...

Get Oracle® PL/SQL® Interactive Workbook, Second 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.