1 Final
1 Final
1 Final
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5
(Answer all questions in this section)
Correct
2. There are 12 distinct JOB_IDs in the EMPLOYEES table. You need to write some PL/SQL Mark for Review
code to fetch and display all the employees with a specific JOB_ID. The chosen JOB_ID
can be different each time the code is executed. (1) Points
What is the best way to do this?
Write a single PL/SQL block which declares one cursor using a parameter for the
JOB_ID. (*)
Write a single PL/SQL block which uses a cursor to fetch all the employee rows, with
an IF statement to decide which of the fetched rows to display.
Write a single PL/SQL block which declares 12 cursors, one for each distinct value of
JOB_ID.
Write 12 separate PL/SQL blocks, each declaring a cursor with a different JOB_ID in
the WHERE clause.
Correct
Record (*)
Cursor
Scalar
Row
Correct
To display the fetched last name, what should you code at Point A?
v_emp_rec.last_name (*)
last_name
v_emp_rec
None of these.
v_emp_rec(last_name)
Correct
There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and display
only the first 25 rows.
Correct
Section 5
(Answer all questions in this section)
6. What will happen when the following code is executed? Mark for Review
Correct
7. You must make sure you have the same number of variables in your INTO statement Mark for Review
as you have in your SELECT list. True or False?
(1) Points
True (*)
False
Correct
Correct
9. An explicit cursor must always be declared, opened, and closed by the PL/SQL Mark for Review
programmer. True or False?
(1) Points
TRUE
FALSE (*)
Correct
10. You want to produce a report which displays each department and (immediately after Mark for Review
each department) a list of employees who work in that department. You declare a
DEPARTMENTS cursor as: (1) Points
CURSOR dept_curs IS
SELECT * FROM departments
ORDER BY department_id;
Correct
Section 5
(Answer all questions in this section)
11. Which of the following is a good reason to declare and use multiple cursors in a single Mark for Review
PL/SQL block?
(1) Points
Multiple cursors can be opened many times, while a single cursor can be opened
only once.
Multiple cursors are the only way to use cursors with parameters.
Multiple cursors use less memory than a single cursor.
Multiple cursors allow us to fetch rows from two or more related tables without
using a JOIN. (*)
Multiple cursors improve performance. They are faster than using a single cursor.
Correct
12. If the rows you attempt to reserve using FOR UPDATE have already been locked by Mark for Review
another session and you use the NOWAIT option, what is the outcome?
(1) Points
Your rows will override the other user's lock and your block will execute
successfully.
The block executes successfully with no errors.
An Oracle server error occurs. (*)
The server will wait until the locks have been released by the other user.
Correct
13. User TOM has locked a row in the WORKERS table. Now, user DICK wants to open the Mark for Review
following cursor:
CURSOR c IS (1) Points
What will happen when DICK opens the cursor and tries to fetch rows?
TOM's session is rolled back. DICK's session successfully fetches rows from the
cursor.
The c%NOWAIT attribute is set to TRUE.
DICK's session waits indefinitely.
Both sessions wait for a few seconds; then the system breaks all locks and both
sessions raise an exception.
DICK's session immediately raises an exception. (*)
Correct
14. What is wrong with the following piece of code? Mark for Review
Correct
To display the salary of an employee, what code should you write at Point A?
employees.salary
emp_record.employees.salary
emp_cursor.salary
emp_record.salary (*)
TO_CHAR(salary)
Correct
Section 5
(Answer all questions in this section)
16. A cursor FOR loop using a subquery can shorten code length when compared to an Mark for Review
explicit cursor declaration. True or False?
(1) Points
True (*)
False
Correct
Section 6
(Answer all questions in this section)
17. An INDEX BY TABLE primary key cannot be negative. Mark for Review
(1) Points
True
False (*)
Correct
18. The following code declares a PL/SQL record with the same structure as a row of the Mark for Review
departments table. True or False?
(1) Points
DECLARE
v_dept_rec departments%ROWTYPE;
...
True (*)
False
Correct
Section 7
(Answer all questions in this section)
19. While a PL/SQL block is executing, more than one exception can occur at the same Mark for Review
time. True or False?
(1) Points
TRUE
FALSE (*)
Correct
20. Examine the following code. Why does this exception handler not follow good practice Mark for Review
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;
Correct
Section 7
(Answer all questions in this section)
21. Which of the following best describes a PL/SQL exception? Mark for Review
(1) Points
The programmer makes a spelling mistake while writiing the PL/SQL code.
A user enters an invalid password while trying to log on to the database.
A DML statement does not modify any rows.
An error occurs during execution which disrupts the normal operation of the
program. (*)
Correct
22. 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;
None of these.
A
A
C
D
A
B
D
A
D
(*)
Correct
23. What will be displayed when the following code is executed? Mark for Review
Correct
24. Which of the following best describes a predefined Oracle Server error? Mark for Review
(1) Points
Has a standard Oracle error number and a standard name which can be
referenced in the EXCEPTION section (*)
Is not raised automatically but must be declared and raised explicitly by the
PL/SQL programmer
Is associated with an Oracle error number using PRAGMA EXCEPTION_INIT
Has a standard Oracle error number but must be named by the PL/SQL
programmer
Correct
25. Examine the following code. At Line A, you want to raise an exception if the Mark for Review
employee's manager_id is null. What kind of exception is this?
(1) Points
DECLARE
v_mgr_id employees.manager_id%TYPE;
BEGIN
SELECT manager_id INTO v_mgr_id FROM employees
WHERE employee_id = 100;
IF v_mgr_id IS NULL THEN
-- Line A
END IF;
...
A NO_DATA_FOUND exception
A constraint violation
A predefined Oracle Server exception
A non-predefined Oracle server exception
A user-defined exception (*)
Correct
Section 7
(Answer all questions in this section)
26. Which kinds of exceptions are raised implicitly (i.e., automatically)? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
All errors
Predefined Oracle Server errors such as NO_DATA_FOUND (*)
Non-predefined Oracle Server errors such as ORA-01400 (*)
User-defined errors
Correct
27. No employees are in department_id 99. What output will be displayed when the Mark for Review
following code is executed?
(1) Points
DECLARE
v_count NUMBER;
BEGIN
SELECT COUNT(*) INTO v_count
FROM employees WHERE department_id = 99;
IF v_count = 0 THEN
RAISE NO_DATA_FOUND;
DBMS_OUTPUT.PUT_LINE('No employees found');
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('Department 99 is empty');
END;
Correct
28. Which of the following will successfully return a user-defined error message? Mark for Review
(1) Points
RAISE_APPLICATION_ERROR(-29001,'Error Raised');
RAISE_APPLICATION_ERROR('Error Raised',-22001);
RAISE_APPLICATION_ERROR('Error Raised',-20257);
RAISE_APPLICATION_ERROR(-20257,'Error raised'); (*)
Correct
29. User-defined exceptions must be declared explicitly by the programmer, but then are Mark for Review
raised automatically by the Oracle Server. True or False?
(1) Points
TRUE
FALSE (*)
Correct
Section 8
(Answer all questions in this section)
30. Suppose you set up a parameter with an explicit IN mode. What is true about that Mark for Review
parameter?
(1) Points
It acts like a constant (its value cannot be changed inside the subprogram). (*)
It cannot have a DEFAULT value.
It must be the same type as the matching OUT parameter.
It must have a DEFAULT value.
It inherits its type from the matching OUT parameter.
Correct
Section 8
(Answer all questions in this section)
31. Procedure SOMEPROC has five parameters named A, B, C, D, E in that order. The Mark for Review
procedure was called as follows:
(1) Points
SOMEPROC(10,20,30,D=>50,E=>60);
Named
Positional (*)
A combination of named and defaulted
A combination of positionally and named
Defaulted
32. Why will the following procedure fail? Mark for Review
Correct
33. You are always able to view and reload your PL/SQL stored procedure's code at a later Mark for Review
point by clicking on the History button in the APEX SQL Commands window. True or
False? (1) Points
True
False (*)
Correct
34. A PL/SQL stored procedure can accept one or more input parameters and can return Mark for Review
one or more output values to the calling environment. True or False?
(1) Points
TRUE (*)
FALSE
Correct
35. What is the correct syntax to create procedure MYPROC that accepts two number Mark for Review
parameters X and Y?
(1) Points
Correct
Section 8
(Answer all questions in this section)
36. Which of the following is NOT correct coding for a procedure parameter? Mark for Review
(1) Points
(p_param IN VARCHAR2)
(p_param VARCHAR2)
(p_param VARCHAR2(50)) (*)
(p_param IN NUMBER)
(p_param employees.last_name%TYPE)
Correct
Section 9
(Answer all questions in this section)
37. Function DOUBLE_SAL has been created as follows: CREATE OR REPLACE FUNCTION Mark for Review
double_sal (p_salary IN employees.salary%TYPE) RETURN NUMBER IS BEGIN
RETURN(p_salary * 2); END; Which of the following calls to DOUBLE_SAL will NOT (1) Points
work?
Correct
38. The following function has been created: Mark for Review
(*)
Correct
39. The function avg_ann_sal returns the average annual salary for a particular Mark for Review
department. The example below is a valid use of this function. True or False?
(1) Points
SELECT first_name, last_name
FROM employees
WHERE avg_ann_sal(20) > 15000;
True (*)
False
Correct
40. User DIANE owns a DEPARTMENTS table. User JOEL needs to update the location_id Mark for Review
column of Diane's table, but no other columns. Which SQL statement should Diane
execute to allow this? (1) Points
Correct
Section 9
(Answer all questions in this section)
41. JOE's schema contains a COUNTRIES table. The following commands are executed by Mark for Review
JOE and TOM:
(JOE): GRANT SELECT ON countries TO tom WITH GRANT OPTION; (1) Points
(TOM): GRANT SELECT on joe.countries TO dick WITH GRANT OPTION;
Nothing. DICK's privilege is preserved even though TOM lost his privilege.
DICK also loses his SELECT privilege. (*)
The REVOKE statement fails because JOE must remove the SELECT privilege from
both users at the same time.
The REVOKE statement fails because only the Database Administrator (not JOE)
can revoke privileges.
HELP DICTIONARY
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'user%table%';
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'USER%TAB%';
(*)
SELECT *
FROM USER_OBJECTS
WHERE table_name LIKE '%TABLE%';
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'DBA%TABLE%';
Correct
43. User JOHN wants to see the names of all the tables in his schema. He does NOT want Mark for Review
to see the names of any tables in other users' schemas. Which Dictionary view should
he query? (1) Points
USER_TABLES (*)
DICTIONARY
ALL_TABLES
JOHN_TABLES
DBA_TABLES
44. Which of the following best describes a stored function? Mark for Review
(1) Points
Correct
45. Which of the following is a difference between a procedure and a function? Mark for Review
(1) Points
A procedure can have default values for parameters, while a function cannot.
A function must return a value; a procedure may or may not. (*)
A function cannot be used within a SQL statement; a procedure can be used
within SQL.
Functions cannot be nested; procedures can be nested to at least 8 levels.
An explicit cursor can be declared in a procedure, but not in a function.
Correct
Section 9
(Answer all questions in this section)
46. You have created a function called GET_COUNTRY_NAME which accepts a country_id Mark for Review
as an IN parameter and returns the name of the country. Which one of the following
calls to the function will NOT work? (1) Points
v_name := get_country_name(100);
BEGIN get_country_name(100, v_name); END; (*)
DBMS_OUTPUT.PUT_LINE(get_country_name(100));
SELECT get_country_name(100) FROM dual;
Correct
47. Procedure ins_emp accepts an employee_id as an IN parameter and attempts to insert Mark for Review
a row with that employee_id into the EMPLOYEES table. Ins_emp does not contain an
exception section. A second procedure is created as follows: (1) Points
When call_ins_emp is executed, (assuming Auto Commit is turned on), which rows will
be inserted into the EMPLOYEES table?
999 only
All three rows will be inserted
99 only (*)
99 and 999
No rows will be inserted
Correct
48. You want to see the names, modes, and data types of the formal parameters of Mark for Review
function MY_FUNC in your schema. How can you do this? (Choose two)
(1) Points
Correct
49. Users SYS (the DBA), TOM, DICK, and HARRY each have an EMPLOYEES table in their Mark for Review
schemas. SYS creates a procedure DICK.SEL_EMP using Invoker's Rights which
contains the following code: (1) Points
HARRY now executes the procedure. Which employees table will be queried?
HARRY.EMPLOYEES (*)
SYS.EMPLOYEES
None of these.
DICK.EMPLOYEES
Correct
50. Which statement is true regarding the following subprogram? Mark for Review