PL/SQL Errors - PL/SQL (MCQ) questions and answers

Here, you can read PL/SQL Errors multiple choice questions and answers with explanation.

1)    ________ does not correlate with an oracle error, instead, user_define exceptions usually enforce business rules in situations in which an oracle error would not necessarily occur
- Published on 08 Jul 15

a. Predefined Exception
b. Internal Exception
c. User defined Exception
d. None of the above
Answer  Explanation 

ANSWER: User defined Exception

Explanation:
PL/SQL allows to raise our own exceptions. A user defined exception is declared explicitly using the raise statement.


2)   Which PL/SQL warning categories gives Messages for conditions that do not have an effect on performance or correctness, but that you might want to change to make the code more maintainable, such as unreachable code that can never be executed?
- Published on 08 Jul 15

a. PERFORMANCE
b. SEVERE
c. INFORMATIONAL
d. All mentioned above
Answer  Explanation 

ANSWER: INFORMATIONAL

Explanation:
No explanation is available for this question!


3)   In internal exception oracle raises the exception for you implicitly. You still need to declare the exception and handle it, but you don’t need to raise it.
- Published on 08 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
In the internal exception a technique is used to bind a numbered exception handler using the PRAGMA_EXCEPTION_INIT() which is a compiler direction. This PRAGMA calls a pre-compiler which binds the exception handler. The EXCEPTION_INIT() takes in the parameters.


4)   Which of the following is handled with the help of exception-handling section in an PL/SQL block. For eg, SELECT INTO statement, which does not return any rows.
- Published on 07 Jul 15

a. A runtime error
b. A syntax error
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: A runtime error

Explanation:
The exception-handling section is a special section of a PL/SQL block where the errors are specified.


5)   For a user-defined exception, SQLCODE returns 1, and SQLERRM returns ___________.
- Published on 07 Jul 15

a. “User-defined Exception”
b. 1
c. 0
d. None of the above
Answer  Explanation 

ANSWER: “User-defined Exception”

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.


6)   Which of the following returns the current error message text?
- Published on 19 Oct 15

a. SQLERRM
b. SQLCODE
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: SQLERRM

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.


7)   When creating a function, in which section will you typically find a return key word?
- Published on 19 Oct 15

a. Header Only
b. Declarative
c. Executable and Header
d. Executable and exception handling
Answer  Explanation 

ANSWER: Executable and Header

Explanation:
The return keyword is an executable statement. It is mandatory to write this keyword in a function.


8)   Which Exception is also known as Oracle named exception handler?
- Published on 03 Jul 15

a. Predefined Exception
b. Internal Exception
c. User defined Exception
d. None of the above
Answer  Explanation 

ANSWER: Predefined Exception

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.


9)   PL/SQL provides a feature to handle the Exceptions which occur in a PL/SQL Block known as exception Handling.
- Published on 03 Jul 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
An exception handling block is used so that we can avoid the errors in the program. The exception message consists of
1. Type of exception
2. An error code
3. A message


10)   The keyword All is a shorthand way to refer to all warning messages.
- Published on 01 Jul 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
The all keyword will handle all the errors. We need not name any of the error in specific.


1 2