Oracle Database Programming MCQs with Answers
Practice important Oracle Database Programming MCQs with answers and explanations.
Chapter: 13
Q201:
What is the output of the program if `due_date` is less than `todays_date` in the `Implementing User Defined Exception –III` example?
A. Handling PAST_DUE exception in Global declaration.
B. Could not recognize PAST_DUE_EXCEPTION in this scope.
C. Valid Salary
D. No Data Found
Correct Answer:
A
Chapter: 13
Q202:
Which section of the PL/SQL block cannot have User Defined Exceptions?
A. Begin Section
B. Declare Section
C. Exception Section
D. End Section
Correct Answer:
A
Chapter: 13
Q203:
What happens if an exception is not handled in the current block?
A. The program ignores the exception
B. The exception is raised again in the current block
C. The exception is passed to the outer block for handling
D. The program terminates immediately
Correct Answer:
C
Chapter: 13
Q204:
What does the `DBMS_OUTPUT.PUT_LINE` statement do in the provided examples?
A. Displays messages or output during program execution
B. Terminates the program
C. Handles the exception
D. Raises the exception
Correct Answer:
A
Chapter: 13
Q205:
What will the output be if `new_sal` is greater than or equal to `min_sal` in the `Implementing User Defined Exception –II` example?
A. Salary is less than the defined minimum
B. Valid Salary
C. No Data Found
D. Invalid Operation
Correct Answer:
B
Chapter: 13
Q206:
What is the correct way to handle multiple exceptions in a PL/SQL block?
A. Using multiple `WHEN` clauses within the `EXCEPTION` section
B. Using multiple `BEGIN` blocks
C. Using multiple `DECLARE` sections
D. Using nested `IF` statements
Correct Answer:
A
Chapter: 14
Q207:
What is the purpose of the `raise_application_error` procedure in PL/SQL?
A. To issue user-defined ORA-error messages
B. To handle exceptions automatically
C. To log errors in a file
D. To terminate the PL/SQL block
Correct Answer:
A
Chapter: 14
Q208:
What is the range of the error number that can be used with `raise_application_error`?
A. -10000 to -10999
B. -15000 to -15999
C. -20000 to -20999
D. -25000 to -25999
Correct Answer:
C
Chapter: 14
Q209:
Which statement is used to raise a user-defined exception with a custom error message?
A. RAISE_APPLICATION_ERROR
B. THROW_ERROR
C. Raise
D. EXCEPTION_INIT
Correct Answer:
A
Chapter: 14
Q210:
What is the syntax to use `raise_application_error` in PL/SQL?
A. RAISE_APPLICATION_ERROR(error_number, message[, {TRUE | FALSE}])
B. RAISE_APPLICATION_ERROR(message, error_number)
C. RAISE_APPLICATION_ERROR(error_number, message)
D. RAISE_APPLICATION_ERROR(message, error_number, {TRUE | FALSE})
Correct Answer:
C
Chapter: 14
Q211:
In the provided `Implementing Raise_application_error – I` example, what happens if `salary < 5000`?
A. An error message is raised using `raise_application_error`
B. `Valid Salary` is displayed
C. `Invalid Salary` is displayed
D. No output is displayed
Correct Answer:
A
Chapter: 14
Q212:
What will be the output if `v_ename` is NULL in the `Implementing User Defined Exception –II` example?
A. No name for empno
B. The employee is validated without errors
C. No data found for empno
D. The job field is missing
Correct Answer:
A
Chapter: 14
Q213:
What does the `EXCEPTION_INIT` pragma do?
A. It associates a user-defined exception with an Oracle error code
B. It handles runtime errors automatically
C. It logs exceptions in a file
D. It raises a built-in exception
Correct Answer:
A
Chapter: 14
Q214:
What is the syntax for using `EXCEPTION_INIT` pragma?
A. DECLARE exception_name EXCEPTION; PRAGMA EXCEPTION_INIT(exception_name, error_number); BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
B. DECLARE exception_name EXCEPTION; PRAGMA EXCEPTION_INIT(exception_name, error_number); BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
C. DECLARE exception_name EXCEPTION; PRAGMA EXCEPTION_INIT(exception_name, error_number); BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
D. DECLARE exception_name EXCEPTION; PRAGMA EXCEPTION_INIT(exception_name, error_number); BEGIN statements; EXCEPTION WHEN exception_name THEN action; END;
Correct Answer:
A
Chapter: 14
Q215:
In the `Implementing Exception_init Pragma –I` example, what is associated with the error code 100?
A. `FOUND_NOTHING` exception
B. `DEADLOCK_DETECTED` exception
C. `INVALID_SALARY` exception
D. `NO_DATA_FOUND` exception
Correct Answer:
A
Chapter: 14
Q216:
What will be displayed if a deadlock is detected in the `Implementing Exception_init Pragma –II` example?
A. Deadlock is detected
B. ORA-00060: deadlock detected
C. An error message from `dbms_output`
D. No data is found
Correct Answer:
A
Chapter: 14
Q217:
What is the output of the `Implementing Raise_application_error – I` example if `salary` is not less than `5000`?
A. Valid Salary
B. InValid Salary
C. No data found
D. Error message is raised
Correct Answer:
B
Chapter: 14
Q218:
Which section of the PL/SQL block contains the `RAISE_APPLICATION_ERROR` statement?
A. Begin Section
B. Declare Section
C. Exception Section
D. End Section
Correct Answer:
A
Chapter: 14
Q219:
What will happen if you use `RAISE_APPLICATION_ERROR` with an error number outside the range -20000 to -20999?
A. The PL/SQL block will terminate immediately
B. A custom error message will be displayed
C. The PL/SQL block will continue execution
D. An error message will be displayed indicating an invalid error number
Correct Answer:
B
Chapter: 14
Q220:
What type of exceptions can `EXCEPTION_INIT` pragma be used to handle?
A. Only Oracle predefined exceptions
B. Only user-defined exceptions
C. Oracle predefined exceptions with custom messages
D. Only runtime exceptions
Correct Answer:
C