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

<pre><code>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;
</code></pre>

<p>I appreciate any suggestion or guidance. Thank you.</p>

You can set a variable before the given statements. Like;
```
```
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;
statementIndex number(1, 0);

BEGIN

statementIndex := 1;
SELECT description into v_book_desc FROM book WHERE book_id = book_id_in;

...

statementIndex := 2;
SELECT emp_name into v_emp_name FROM emp WHERE emp_id = emp_id_in;

...

EXCEPTION WHEN NO_DATA_FOUND THEN 
if statementIndex = 1
then 
/* Do something */
else
/* Do something */
endif;

END TEST_EXCEPTION;
```
```