Semester 1 Final Exam
Semester 1 Final Exam
Semester 1 Final Exam
Section 5
(Answer all questions in this section)
INDEX BY VIEW
Correct Correct
2. You can use %ROWTYPE with tables and views. Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 6
SEMESTER 1 FINAL EXAM
Your block fails because you should have coded: FOR UPDATE WAIT (10);
Your session waits for 10 seconds, and then returns control to your block so that it can continue
to execute. (*)
Correct Correct
After opening the cursor and fetching some rows, you want to delete the most recently fetched row.
Which of the following will do this successfully?
None of these.
Correct Correct
END LOOP;
Correct Correct
Section 6
(Answer all questions in this section)
6. When using a cursor FOR loop, OPEN, CLOSE, and FETCH statements should not
be explicitly coded. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
FOR emp_rec IN
(SELECT * FROM employees WHERE department_id = 75) LOOP ...
FOR emp_rec IN
(SELECT last_name, salary FROM employees) LOOP ...
FOR emp_rec IN
(SELECT last_name, salary FROM employees ORDER BY last_name) LOOP ...
SEMESTER 1 FINAL EXAM
FOR emp_rec IN
(SELECT * FROM employees) LOOP ...
Correct Correct
8. Assume that table BIGDEPTS contains 100 rows, and table BIGEMPS contains
1000 rows, with 10 employees in each department. Consider the following code:
DECLARE
CURSOR bigdept_cur IS
SELECT * FROM bigdepts;
CURSOR bigemp_cur IS
SELECT * FROM bigemps;
BEGIN
FOR dept_rec IN bigdept_cur LOOP
DBMS_OUTPUT.PUT_LINE (dept_rec.department_name);
FOR emp_rec IN bigemp_cur LOOP
IF emp_rec.department_id=dept_rec.department_id
THEN DBMS_OUTPUT.PUT_LINE (emp_rec.last_name);
END IF;
END LOOP;
END LOOP;
END;
It reads 1000 employee rows every time BIGEMP_CUR is OPENed, and then ignores 990 of them.
(*)
It is doing a Cartesian Product, joining every employee with every department and displaying
1100 lines of output.
SEMESTER 1 FINAL EXAM
It is using cursor FOR loops, which are less efficient than OPENing and CLOSEing the cursors
explicitly.
Correct Correct
EMP_CURS should not be DECLAREd explicitly; it should be coded as a subquery in a cursor FOR
loop.
Nothing is wrong. The block will execute successfully and display all departments and the
employees in those departments. (*)
You cannot use two different kinds of loops in a single PL/SQL block.
Correct Correct
OPEN emp_curs;
FETCH emp_curs;
OPEN emp_curs;
FETCH emp_curs INTO v_last_name, v_salary;
(*)
OPEN emp_curs;
FETCH emp_curs INTO v_salary, v_last_name;
OPEN emp_curs;
FETCH FIRST emp_curs INTO v_last_name, v_salary;
SEMESTER 1 FINAL EXAM
Correct Correct
Section 6
(Answer all questions in this section)
At Point A (after you have OPENed the cursor) another user updates an employee's last_name from
'Smith' to 'Jones' and immediately COMMITs.
When your block FETCHes this row, which value will be fetched and displayed?
An INVALID_CURSOR exception will be raised when you try to FETCH the row.
Smith (*)
Jones
Correct Correct
12. Which of these is NOT a valid cursor declaration? Mark for Review
(1) Points
CURSOR emp_curs IS
SELECT salary
FROM employees
ORDER BY salary DESC;
CURSOR emp_curs IS
SELECT salary
FROM employees
WHERE last_name LIKE 'S%';
CURSOR emp_dept_curs IS
SELECT e.salary, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id;
CURSOR emp_curs IS
SELECT salary INTO v_salary
FROM employees;
(*)
Correct Correct
DECLARE
CURSOR dept_curs IS SELECT department_name FROM departments;
v_dept_name departments.department_name%TYPE;
BEGIN
OPEN dept_curs;
LOOP
FETCH dept_curs INTO v_dept_name;
DBMS_OUTPUT.PUT_LINE(v_dept_name);
EXIT WHEN dept_curs%NOTFOUND;
END LOOP;
CLOSE dept_curs;
END;
There are 10 rows in the DEPARTMENTS table. What will happen when this code is executed?
The loop will execute forever; the same 10 rows will be displayed over and over again.
Correct Correct
You want to open the cursor, passing value 50 to the parameter. Which of the following are correct at
Point A?
50
v_deptid
100 / 2
Correct Correct
A parameter is missing. The parameter should be coded as: (p_loc_id NUMBER) (*)
The declaration is invalid. You cannot reference a cursor parameter in a WHERE clause.
Section 6
(Answer all questions in this section)
There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and display only the first 25
rows.
Correct Correct
Cursor
Scalar
Record (*)
Row
Correct Correct
18. You can reference explicit cursor attributes directly in a SQL statement. True or
False? Mark for Review
(1) Points
True
False (*)
SEMESTER 1 FINAL EXAM
Correct Correct
Section 7
(Answer all questions in this section)
TRUE (*)
FALSE
Correct Correct
20. While a PL/SQL block is executing, more than one exception can occur at the
same time. True or False? Mark for Review
(1) Points
TRUE
FALSE (*)
SEMESTER 1 FINAL EXAM
Correct Correct
Section 7
(Answer all questions in this section)
21. 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;
Mark for Review
(1) Points
The exception handler should test for the named exception NO_DATA_FOUND. (*)
The exception section should include a WHEN TOO_MANY_ROWS exception handler. (*)
SEMESTER 1 FINAL EXAM
Correct Correct
TRUE (*)
FALSE
Correct Correct
True
False (*)
Correct Correct
DBMS_OUTPUT.PUT_LINE('Message 3');
RAISE e_myexcep;
DBMS_OUTPUT.PUT_LINE('Message 4');
END;
Mark for Review
(1) Points
The code will execute but will return an unhandled exception to the calling environment.
(*)
Message 1
Message 3
Message 4
Message 1
Message 3
The code will not execute because it contains at least one syntax error.
Message 1
Message 2
Message 3
Message 4
Correct Correct
25. Examine the followiing code. Which exception handlers would successfully trap
the exception which will be raised when this code is executed? (Choose two.)
DECLARE
CURSOR emp_curs IS SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE;
BEGIN
FETCH emp_curs INTO v_emp_rec;
SEMESTER 1 FINAL EXAM
OPEN emp_curs;
CLOSE emp_curs;
EXCEPTION ...
END;
Mark for Review
(1) Points
WHEN INVALID_FETCH
WHEN CURSOR_NOT_OPEN
WHEN NO_DATA_FOUND
Correct 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
All errors
User-defined errors
Correct Correct
27. Which of the following best describes a user-defined exception? Mark for
Review
(1) Points
Any error which has an Oracle error number of the form ORA-nnnnn
Correct Correct
True (*)
SEMESTER 1 FINAL EXAM
False
Correct Correct
25
100
30 (*)
40
35
SEMESTER 1 FINAL EXAM
Correct Correct
Section 8
(Answer all questions in this section)
30. Which of the following are benefits of using PL/SQL subprograms rather than
anonymous blocks? (Choose three.) Mark for Review
(1) Points
Easier to write
Section 8
(Answer all questions in this section)
SEMESTER 1 FINAL EXAM
31. A PL/SQL procedure named MY_PROC1 has been successfully created in the
database. The procedure has no parameters. Which of the following will successfully invoke the
procedure in Application Express? (Choose two.) Mark for Review
(1) Points
EXECUTE my_proc1;
DECLARE
v_var1 NUMBER := 20;
BEGIN
my_proc1(v_var1);
END;
BEGIN
my_proc1;
END;
(*)
32. Which of the following are characteristics of PL/SQL stored procedures? (Choose
three.) Mark for Review
SEMESTER 1 FINAL EXAM
(1) Points
Correct Correct
33. Which of the following is NOT correct coding for a procedure parameter?
Mark for Review
(1) Points
(p_param IN NUMBER)
(p_param IN VARCHAR2)
(p_param employees.last_name%TYPE)
(p_param VARCHAR2)
SEMESTER 1 FINAL EXAM
Correct Correct
34. Which of the following best describes how an input parameter affects a
procedure? Mark for Review
(1) Points
It passes a value into the procedure when the procedure is invoked. (*)
35. What are the types of parameter modes? Mark for Review
(1) Points
Correct Correct
Section 8
(Answer all questions in this section)
36. Which of the following statements about IN OUT parameters are true? (Choose
two.) Mark for Review
(1) Points
The parameter value passed into the subprogram is always returned unchanged to the calling
environment.
The parameter value can be returned as a new value that is set within the procedure. (*)
The parameter value can be returned as the original unchanged value. (*)
Section 9
(Answer all questions in this section)
37. Your schema contains two procedures named CHILD1 and CHILD2. You now
create a third procedure by executing:
CREATE OR REPLACE PROCEDURE parent IS
SEMESTER 1 FINAL EXAM
BEGIN
child1;
child2;
END;
You now want user JOE to be able to invoke PARENT. Which of the following gives JOE the privileges he
needs, but no unnecessary privileges?
38. You want to allow user JOE to query the CD_DETAILS table in your schema.
Which command should you use? Mark for Review
(1) Points
Correct Correct
39. Which of the following is the correct syntax to create a procedure using
Invoker's Rights? Mark for Review
(1) Points
Correct Correct
User BILL wants to execute this procedure. What privileges will BILL need?
EXECUTE on REYHAN.PROC1
None of these. The procedure will fail to compile because REYHAN does not have SELECT
privilege on TOM.EMPLOYEES.
SELECT on TOM.EMPLOYEES
Correct Correct
Section 9
(Answer all questions in this section)
SEMESTER 1 FINAL EXAM
41. Which of the following best describes the Data Dictionary? Mark for
Review
(1) Points
It is a set of tables which can be updated by any user who has the necessary privileges.
It contains a list of all database tables which are not in any schema.
It is an automatically managed master catalog of all the objects stored in the database. (*)
42. User BOB is not a database administrator. BOB wants to see the names of all the
tables in his schema, as well as all the tables in other users' schemas which he has privileges to use.
Which Data Dictionary view would BOB query to do this? Mark for Review
(1) Points
None of these.
USER_TAB_COLUMNS
DBA_TABLES
ALL_TABLES (*)
USER_TABLES
SEMESTER 1 FINAL EXAM
Correct Correct
The data type for the tax variable does not match the data type for salary.
(1) Points
Correct Correct
45. When creating a user-defined function that will be called from a SQL statement,
the size of the returned values may be up to the size of any PL/SQL data type. True or False? Mark
for Review
(1) Points
True
False (*)
Section 9
(Answer all questions in this section)
17 (*)
11
66
23
An error message will be displayed because you cannot nest user-defined functions.
Correct Correct
A function must have at least one IN parameter, while parameters are optional for a procedure.
A function can be used inside a SQL statement, while a procedure cannot. (*)
DECLARE
x NUMBER;
BEGIN
x:= add_em(b=4);
END;
(*)
DECLARE
x NUMBER;
BEGIN
x:= add_em(4);
END;
DECLARE
x NUMBER;
BEGIN
x:= add_em(4,5);
END;
SEMESTER 1 FINAL EXAM
DECLARE
x NUMBER;
BEGIN
x:= add_em;
END;
Correct Correct
49. The following code shows the dependencies between three procedures:
CREATE PROCEDURE parent
IS BEGIN
child1;
child2;
END parent;
You now try to execute:
CHILD2 is dropped successfully. PARENT is marked INVALID, but CHILD1 is still valid. (*)
CHILD2 is dropped successfully. PARENT and CHILD1 are both marked INVALID.
Correct Correct
50. Which Data Dictionary view can be used to display the detailed code of a
procedure in your schema? Mark for Review
(1) Points
USER_SOURCE (*)
USER_OBJECTS
USER_PROCEDURES
USER_SUBPROGRAMS
None of these