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 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 ...

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