Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Quiz
(Answer all questions in this section)
1.What is the correct syntax to associate an exception named EXCEPNAME with the non-
predefined Oracle Server error ORA-02292? Mark for Review
(1) Points
SQLCODE (-2292, excepname);
Correct
2.Which of these exceptions would need to be raised explicitly by the PL/SQL programmer?
Mark for Review
(1) Points
A check constraint is violated.
OTHERS
Correct
3.Which kinds of exceptions are raised implicitly (i.e., automatically)? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
Predefined Oracle Server errors such as NO_DATA_FOUND (*)
All errors
User-defined errors
Correct
4.How would you trap Oracle Server exception ORA-01403: no data found?
Mark for Review
(1) Points
WHEN NO DATA FOUND THEN ...
5.An ORA-1400 exception is raised if an attempt is made to insert a null value into a NOT
NULL column. DEPARTMENT_ID is the primary key of the DEPARTMENTS table. What will Mark for Review
happen when the following code is executed? (1) Points
DECLARE
e_not_null EXCEPTION;
BEGIN
PRAGMA EXCEPTION_INIT(e_not_null, -1400);
INSERT INTO departments (department_id, department_name)
VALUES(null, 'Marketing');
EXCEPTION
WHEN e_not_null THEN
DBMS_OUTPUT.PUT_LINE('Cannot be null');
END;
The exception will be raised and "Cannot be null" will be displayed.
The code will not execute because the syntax of the INSERT statement is wrong.
The code will not execute because PRAGMA EXCEPTION_INIT must be coded in the
DECLARE section. (*)
The code will not execute because the syntax of PRAGMA EXCEPTION_INIT is
wrong.
Correct
Section 7 Quiz
None of these.
Any other kind of exception that can occur within the block
Correct
7. Which of the following EXCEPTION sections are constructed correctly? (Choose two.)
Mark for Review
(1) Points
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;
EXCEPTION
WHEN OTHERS THEN statement_1;
END;
(*)
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
END;
(*)
EXCEPTION
WHEN OTHERS THEN statement_2;
WHEN NO_DATA_FOUND THEN statement_1;
END;
Correct
8. Examine the following code. Why does this exception handler not follow good practice
guidelines? Mark for Review
(1) Points
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 999;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;
The exception handler should test for the named exception NO_DATA_FOUND. (*)
Correct
Code is more readable because error-handling routines can be written in the same
block in which the error occurred
Correct
True (*)
False
Correct
Section 7 Quiz
40
10
20 (*)
200
30
Correct
By PRAGMA EXCEPTION_INIT
Correct
13.User-defined exceptions must be declared explicitly by the programmer, but then are
raised automatically by the Oracle Server. True or False? Mark for Review
(1) Points
TRUE
FALSE (*)
Correct
14.Department-id 99 does not exist. What will be displayed when the following code is
executed? Mark for Review
(1) Points
DECLARE
v_deptname departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_deptname
FROM departments WHERE department_id = 99;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20201,'Department does not exist');
END;
None of these.
Correct
15.A user-defined exception must be declared as a variable of data type EXCEPTION. True
or False? Mark for Review
(1) Points
TRUE (*)
FALSE
Correct