PL/SQL Error Handling Interview Question and Answers

5. What causes the INVALID_CURSOR exception?
  • This exception is raised when the program attempts to perform an illegal operation, such as closing an unopened cursor.
6. Describe the SQLCODE and SQLERRM functions?
  • The SQLCODE function returns the Oracle error number for internal exceptions.
  • This error number can be passed to the SQLERRM function to get the message associated with the error number.
  • The SQLCODE function returns the value +1; whereas, the SQLERRM function returns the User Defined Exception message for the user defined exceptions.
7. What happens to the program control when the RAISE_APPLICATION_ ERROR procedure is encountered?
  • When the RAISE_APPLICATION_ERROR procedure is encountered, it ends the program unit and returns the error number and message to the application.
  • The error number and message can be trapped like any Oracle error.
8. When is the CURSOR_ALREADY_OPEN exception raised?
  • This exception is raised when the program tries to open an already opened cursor.
  • The cursor should be closed before it can be opened again.
Page 2 of 6 1 23456