Quiz 7
Quiz 7
Quiz 7
(1) Points
DECLARE
e_sal_excep EXCEPTION;
PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290);
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290); (*)
DECLARE
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;
Correct
2. A PL/SQL block executes and an Oracle Server exception is raised. Which
of the following contains the text message associated with the exception?
Mark for Review
(1) Points
SQL_MESSAGE_TEXT
SQLERRM (*)
SQL%MESSAGE
SQLCODE
Correct
(1) Points
A database constraint is violated. (*)
A SELECT statement returns exactly one row.
The PL/SQL programmer mis-spells the word BEGIN as BEGAN.
An UPDATE statement modifies no rows.
Correct
(1) Points
DUP_VAL_ON_INDEX
ZERO_DIVIDE
NO_DATA_FOUND
TOO_MANY_ROWS
e_sal_too_high EXCEPTION; (*)
Correct
(1) Points
Has a standard Oracle error number and a standard name which can be
referenced in the EXCEPTION section (*)
Has a standard Oracle error number but must be named by the PL/SQL
programmer
Is associated with an Oracle error number using PRAGMA EXCEPTION_INIT
Is not raised automatically but must be declared and raised explicitly by the
PL/SQL programmer
Correct
6. The following line of code is correct. True or False?
RAISE_APPLICATION_ERROR(-21001,'My error message');
Mark for Review
(1) Points
True
False (*)
Correct
(1) Points
Line A should be: HANDLE NO_DATA_FOUND
You cannot use SQL%ROWCOUNT in conditional control statements such as
IF or CASE.
You cannot explicitly raise predefined Oracle Server errors such as
NO_DATA_FOUND.
Nothing is wrong; the code will execute correctly. (*)
NO_DATA_FOUND has not been DECLAREd.
Correct
8. You want to display your own error message to the user. What is the
correct syntax to do this?
Mark for Review
(1) Points
RAISE_APPLICATION_ERROR(20001, 'My own message');
RAISE application_error;
RAISE_APPLICATION_ERROR('My own message', -20001);
RAISE_APPLICATION_ERROR (-20001, 'My own message'); (*)
Correct
(1) Points
Message 1
Message 3
Message 4
Message 1
Message 2
Message 1
Message 4 (*)
Message 1
Message 3
Correct
(1) Points
It will compile successfully and return an unhandled e_excep2 to the calling
environment. (*)
It will fail to compile because you cannot declare more than one exception in
the same block.
It will fail to compile because you cannot have a subblock inside an
exception section.
It will fail to compile because e_excep1 is out of scope in the subblock.
Correct
11. No employees exist in department 75. What will be displayed when this
code is executed?
DECLARE
v_last_name employees.last_name%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE('A');
BEGIN
SELECT last_name INTO v_last_name
FROM employees WHERE department_id = 75;
DBMS_OUTPUT.PUT_LINE('B');
END;
DBMS_OUTPUT.PUT_LINE('C');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('D');
END;
(1) Points
A
D (*)
A
C
D
None of these.
A
A
B
D
Correct
(1) Points
An error occurs during the execution of the block, which disrupts the normal
operation of the program. (*)
A user enters an invalid password while trying to log on to the database.
The programmer forgets to declare a cursor while writing the PL/SQL code.
13. Examine the following code. Why does this exception handler not follow
good practice guidelines? (Choose two.)
DECLARE
v_dept_name departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_dept_name FROM departments
WHERE department_id = 75;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('A select returned more than one row');
END;
(1) Points
The exception handler should COMMIT the transaction.
department_id 75 does not exist in the departments table.
The exception section should include a WHEN TOO_MANY_ROWS exception
handler. (*)
You should not use DBMS_OUTPUT.PUT_LINE in an exception handler.
The exception handler should test for the named exception
NO_DATA_FOUND. (*)
Correct
14. Which of the following best describes a PL/SQL exception?
Mark for Review
(1) Points
An error occurs during execution which disrupts the normal operation of the
program. (*)
A user enters an invalid password while trying to log on to the database.
The programmer makes a spelling mistake while writiing the PL/SQL code.
(1) Points
EXCEPTION
WHEN OTHERS THEN statement_1;
END; (*)
EXCEPTION
WHEN TOO_MANY_ROWS THEN statement_1;
END; (*)
EXCEPTION
WHEN OTHERS THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
END;
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
END; (*)
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;
Correct
Previous