I want to use Oracle exception to handle errors that might happen in the code below. If a user provides the book ID and/or employee ID that doesn't exist in the database, NO_DATA_FOUND exception will be raised. Thus, how can I know which statement raises this exception.
CREATE OR REPLACE PROCEDURE TEST_EXCEPTION
(
book_id_in IN book.book_id%TYPE,
emp_id_in IN emp.emp_id%TYPE
)
IS
v_book_desc book.description%TYPE;
v_emp_name emp.emp_name%TYPE;
BEGIN
SELECT description into v_book_desc FROM book WHERE book_id = book_id_in;
...
SELECT emp_name into v_emp_name FROM emp WHERE emp_id = emp_id_in;
...
EXCEPTION
WHEN NO_DATA_FOUND THEN
/* Do something */
END TEST_EXCEPTION;
I appreciate any suggestion or guidance. Thank you.