w3resource

PL/SQL Exception Handling exercises: Handle Common Exceptions in PL/SQL

PL/SQL Exception Handling [ 16 exercises with solution ]

1. Write a PL/SQL block to handle the exception when a division by zero occurs.

Click me to see the solution

2. Handle the NO_DATA_FOUND exception when retrieving a row from a table and no matching record is found.

Click me to see the solution

3. Handle the TOO_MANY_ROWS exception when retrieving multiple rows instead of a single row from a table.

Click me to see the solution

4. Handle the INVALID_NUMBER exception when converting a non-numeric value to a number.

Click me to see the solution

5. Handle the DUP_VAL_ON_INDEX exception when inserting a duplicate value into a table with a unique constraint.

Click me to see the solution

6. Handle the VALUE_ERROR exception when assigning an incompatible value to a variable.

Click me to see the solution

7. Handle the PROGRAM_ERROR exception when a PL/SQL program encounters an internal error.

Click me to see the solution

8. Handle the CURSOR_ALREADY_OPEN exception when trying to open a cursor that is already open.

Click me to see the solution

9. Handle the INVALID_CURSOR exception when referencing an invalid or closed cursor.

Click me to see the solution

10. Handle the COLLECTION_IS_NULL exception when trying to access elements from a NULL collection.

Click me to see the solution

11. Handle the CASE_NOT_FOUND exception when no branch matches the value of a CASE statement.

Click me to see the solution

12. Handle the INVALID_TRANSACTION exception when a transaction is in an invalid state.

Click me to see the solution

13. Handle the SUBSCRIPT_BEYOND_COUNT exception when accessing an array element beyond its declared size.

Click me to see the solution

14. Handle the ROWTYPE_MISMATCH exception when assigning values to variables of incompatible row types.

Click me to see the solution

15. Handle the ACCESS_INTO_NULL exception when trying to access a NULL record.

Click me to see the solution

16. Handle the NO_DATA_NEEDED exception when a query retrieves more data than required.

Click me to see the solution



Follow us on Facebook and Twitter for latest update.