SQL Exception Handling MCQ Questions
11. Which Exception is also known as Oracle named exception handler?
Explanation: A predefined exception is the one which is executed whenever a program violates any database rule. Example of this type of exception can be the exception NO_DATA_FOUND.
12. When creating a function, in which section will you typically find a return key word?
Explanation: The return keyword is an executable statement. It is mandatory to write this keyword in a function.
13. Which of the following returns the current error message text?
Explanation: Using this function the associated error message with the most recent raised error exception is displayed. The exception handling section will display this function.
14. For a user-defined exception, SQLCODE returns 1, and SQLERRM returns ___________.
Explanation: The SQLCODE is useful in an exception handler. SQLCODE is useful to the other exception handlers as it lets you identify the internal exception which is raised. The SQLERRM will return the user defined exception.
15. Which of the following is true?
Explanation: All of the above are TRUE.
16. Which of the following is a global variable for error handling?
Explanation: @@ERROR is one of the basic error handling mechanisms in SQL Server.
17. ERROR_SEVERITY() returns the ________level of the error.
Explanation: ERROR_SEVERITY() returns the severity level of the error.
18. Which of the following is an Error function used within CATCH block?
Explanation: ERROR_STATE() returns the state number of the error.
19. Exception handling is possible in SQL Server using _____________
Explanation: Generates an error message and initiates error processing for the session.
20. Which of the following benefit does Exception handling with the TRY and CATCH blocks provide?
Explanation: Exception handling using the TRY and CATCH statements is the common way that modern programming languages like C# and Java treat errors.