Lab Exer 5
Lab Exer 5
1. What happens when Oracle encounters a runtime problem while executing a PL/SQL
block?
2. What do you need to add to your PL/SQL block to address these problems?
4. Run this PL/SQL code and then answer the questions that follow.
BEGIN
END;
A. What happens when you run the block? In your own words, explain what you can do
to fix this problem.
B. Modify the code to fix the problem. Use a TOO_MANY_ROWS exception handler.
5. Run the following PL/SQL block, which tries to insert a new row (with department_id =
50) into the departments table. What happens and why?
6. Enter the following PL/SQL block, which tries to SELECT all the employees in a
specific department. Run it three times, using department_ids 10, 20, and 30. What
happens and why?
DECLARE
v_employee_id employees.employee_id%TYPE;
v_last_name employees.last_name%TYPE;
BEGIN
END;
7. Modify your code from question 6 to add two more exception handlers to trap the
possible exceptions individually. Use NO_DATA_FOUND and TOO_MANY_ROWS.
Re-run the block three times, using 10, 20, and 30 as before. Observe the message
displayed in each case.
10. Modify the block in question 9 to omit the exception handler, then re-run the block.
Explain the output.