Professional Documents
Culture Documents
1. Which of the following will successfully return a user-defined error message? Mark for Review
(1) Points
RAISE_APPLICATION_ERROR('Error Raised',-22001);
RAISE_APPLICATION_ERROR(-29001,'Error Raised');
RAISE_APPLICATION_ERROR(-20257,'Error raised'); (*)
RAISE_APPLICATION_ERROR('Error Raised',-20257);
Correct
3. The following three steps must be performed to use a user-defined exception: - Raise Mark for Review
the exception - Handle the exception - Declare the exception In what sequence must
these steps be performed? (1) Points
Correct
4. How are user-defined exceptions raised ? Mark for Review
(1) Points
Correct
5. Which of the following are examples of predefined Oracle Server errors? (Choose Mark for Review
three.)
(1) Points
E_INSERT_EXCEP
ZERO_DIVIDE (*)
TOO_MANY_ROWS (*)
OTHERS
NO_DATA_FOUND (*)
SQL%MESSAGE
SQLCODE
SQL_MESSAGE_TEXT
SQLERRM (*)
Correct
7. An attempt to update an employee's salary to a negative value will violate a Mark for Review
check constraint and raise an ORA-02290 exception. Which of the following is a
correct definition of a handler for this exception? (1) Points
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);
DECLARE
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
(*)
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);
DECLARE
e_sal_excep EXCEPTION;
PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290);
Correct
8. You cannot use SQLCODE or SQLERRM directly in an SQL statement. Instead, Mark for Review
you must assign their values to local variables, then use the variables in the SQL
statement (1) Points
True (*)
False
Correct
9. Which one of the following events would implicitly raise an exception? Mark for Review
(1) Points
Correct
10. Which of the following are good practice guidelines for exception handling? Mark for Review
(Choose three.)
(1) Points
Correct
11. Which of Mark for Review
the
following (1) Points
best
describes
a PL/SQL
exception?
An error occurs during the execution of the block, which disrupts the
normal operation of the program. (*)
The programmer forgets to declare a cursor while writing the PL/SQL
code.
A compile-time error occurs because the PL/SQL code references a non-
existent table.
A user enters an invalid password while trying to log on to the database.
Correct
12. Examine the following code. Why does this exception handler not follow good Mark for Review
practice guidelines? (Choose two.)
(1) Points
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;
13. Which of these exceptions can be handled by an EXCEPTION section in a Mark for Review
PL/SQL block?
(1) Points
None of these.
A SELECT statement returns more than one row.
Any other kind of exception that can occur within the block
A SELECT statement returns no rows.
All of these. (*)
14. No employees exist in department 75. What will be displayed when this code is Mark for Review
executed?
(1) Points
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;
A
C
D
A
B
D
None of these.
A
D
(*)
A
15. What will be displayed when the following code is executed? Mark for Review
(1) Points
<< outer>>
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 10;
DECLARE
v_myvar NUMBER := 200;
BEGIN
outer.v_myvar := 20;
v_myvar := v_myvar / 0; -- this raises a ZERO_DIVIDE error
outer.v_myvar := 30;
END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END;
200
20 (*)
40
30
10
Correct