Documente Academic
Documente Profesional
Documente Cultură
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 5
(Answer all questions in this section)
Correct Correct
It must contain one or more components, but all the components must have
scalar datatypes. (*)
Correct Correct
Section 6
(Answer all questions in this section)
3. You execute the following code:
DECLARE
CURSOR emp_curs IS SELECT last_name FROM employees;
v_last_name employees.last_name%TYPE;
BEGIN
OPEN emp_curs;
LOOP -- Point A
FETCH emp_curs INTO v_last_name;
EXIT WHEN emp_curs%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_last_name);
END LOOP;
CLOSE emp_curs;
END;
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?
Smith (*)
An INVALID_CURSOR exception will be raised when you try to FETCH the row.
Jones
Correct Correct
An explicit cursor can select from only one table. No joins are allowed. (*)
You can not use an INTO clause when declaring an explicit cursor.
Incorrect Incorrect. Refer to Section 6 Lesson 1.
Correct Correct
Section 6
(Answer all questions in this section)
The EXIT WHEN ... statement should be coded outside the loop.
There are over 200 rows in the WF_COUNTRIES table, but you want to fetch and
display only the first 25 rows.
Correct Correct
You want to display the id and name of each FETCHed country. What would you code at
Line A?
Correct Correct
The FETCH will fail because the structure of v_dept_rec does not match the
structure of the cursor.
Correct Correct
You cannot reference %ROWCOUNT with a cursor FOR loop using a subquery. (*)
You cannot use FOR UPDATE NOWAIT with a cursor FOR loop using a subquery.
Correct Correct
Section 6
(Answer all questions in this section)
END LOOP;
Correct Correct
12. Which one of the following is a valid cursor FOR loop with a
subquery? Mark for Review
(1) Points
FOR emp_rec IN SELECT last_name, salary*12 "ANNSAL" FROM employees LOOP ...
FOR emp_rec IN (SELECT last_name |and first_name FROM employees) LOOP ...
FOR emp_rec IN (SELECT last_name, salary*12 "ANNSAL" FROM employees) LOOP ...
(*)
None of these.
Correct Correct
13. What is the difference between the following two blocks of code?
--Block A
DECLARE
CURSOR emp_cursor IS
SELECT employee_id, last_name
FROM employees
WHERE department_id = 80
FOR UPDATE OF salary;
--Block B
DECLARE
CURSOR emp_cursor IS
SELECT employee_id, last_name
FROM employees
WHERE department_id = 80
FOR UPDATE OF salary
NOWAIT;
Mark for Review
(1) Points
In Block A, the program waits indefinitely until locked rows are available.
In Block B, control is returned to your program after 5 seconds so that it can do
other work.
In Block A, the program waits indefinitely until locked rows are available.
In Block B, the program returns control immediately so that it can do other work.
(*)
Correct Correct
14. User MARY has locked a row of the EMPLOYEES table. Now, user
SAEED tries to open the following cursor:
CURSOR c IS
SELECT * FROM employees
FOR UPDATE WAIT 5;
What will happen when SAEED's session tries to fetch the row that MARY has locked?
SAEED's session waits for 5 seconds, and then raises an exception if MARY has
not unlocked the row. (*)
SAEED's session successfully fetches the first 5 rows and then waits
indefinitely to fetch the 6th row.
SAEED's session waits for 5 minutes, and then raises an exception if MARY has
not unlocked the row.
SAEED's session waits for 5 seconds, then SAEED is disconnected from the
database.
SAEED's session waits for 5 seconds, then MARY's session is rolled back.
Correct Correct
15. You want to produce a report which displays each department and
(immediately after each department) a list of employees who work in that
department. You declare a DEPARTMENTS cursor as:
CURSOR dept_curs IS
SELECT * FROM departments
ORDER BY department_id;
Correct Correct
Section 6
(Answer all questions in this section)
16. 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 using cursor FOR loops, which are less efficient than OPENing and
CLOSEing the cursors explicitly.
Correct Correct
17. Using parameters with a cursor, you can open and close the cursor
several times in a block, returning a different active set each time. True or
False? Mark for Review
(1) Points
True (*)
False
Correct Correct
18. Examine the following declaration of a cursor with a parameter.
What should be coded at Point A?
DECLARE
CURSOR emp_curs(-- Point A --) IS
SELECT * FROM employees
WHERE job_id = p_job_id;
Mark for Review
(1) Points
ST_CLERK'
p_job_id
p_job_id VARCHAR2(25)
job_id VARCHAR2
Correct Correct
Section 7
(Answer all questions in this section)
Message 1
Message 4
(*)
Message 1
None of these.
Message 1
Message 3
Message 4
Correct Correct
A
B
D
A
D
(*)
None of these.
A
C
D
Correct Correct
Section 7
(Answer all questions in this section)
Correct Correct
WHEN NO_DATA_FOUND
WHEN INVALID_FETCH
Correct Correct
23. Examine the following code. The UPDATE statement will raise an
ORA-02291 exception.
BEGIN
UPDATE employees
SET department_id = 45;
EXCEPTION
WHEN OTHERS THEN
INSERT INTO error_log_table VALUES (SQLCODE);
END;
The code will fail because we cannot use functions like SQLCODE directly in a
SQL statement. (*)
The code will fail because we access error message numbers by using
SQLERRNUM, not SQLCODE.
The code will execute and insert error number 02291 into error_log_table.
The code will fail because SQLCODE has not been declared.
Correct Correct
FLAG exception_name;
RAISE(error_number, exception_name);
PRAGMA EXCEPTION_INIT
Correct Correct
Message 1
Message 3
Message 1
Message 2
Message 1
Message 4
(*)
Message 1
Message 3
Message 4
Correct Correct
Previous Page 5 of 10 Next Summary
Section 7
(Answer all questions in this section)
B and C (*)
A and B
A and C
Correct Correct
27. 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. (*)
Correct Correct
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;
EXCEPTION
WHEN OTHERS THEN statement_1;
END;
(*)
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;
Correct Correct
29. Examine the following code. Why does this exception handler not
follow good practice guidelines?
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;
Mark for Review
(1) Points
The exception handler should test for the named exception NO_DATA_FOUND. (*)
Correct Correct
Section 8
(Answer all questions in this section)
None of these.
An expression
A literal value
Correct Correct
Previous Page 6 of 10 Next Summary
Section 8
(Answer all questions in this section)
Correct Correct
Positionally
Named (*)
Defaulted
Correct Correct
Defaulted
Named
Positional (*)
Correct Correct
34. When modifying procedure code, the procedure code statement must
be re-executed to validate and store it in the database. True or False? Mark
for Review
(1) Points
True (*)
False
Correct Correct
35. Procedures are generally used to perform what? Mark for Review
(1) Points
A SELECT statement
None of these.
All of these.
An action (*)
A return of values
Correct Correct
Section 8
(Answer all questions in this section)
B and C
A and C
A only
A, B and C (*)
A and B
Correct Correct
Section 9
(Answer all questions in this section)
37. When a database object is first created, only its owner (creator)
and the Database Administrator are privileged to use it. True or False? Mark
for Review
(1) Points
True (*)
False
Correct Correct
38. User DIANE owns a DEPARTMENTS table. User JOEL needs to update
the location_id column of Diane's table, but no other columns. Which SQL statement
should Diane execute to allow this? Mark for Review
(1) Points
Correct Correct
When call_ins_emp is executed, (assuming Auto Commit is turned on), which rows will
be inserted into the EMPLOYEES table?
999 only
99 only (*)
99 and 999
Correct Correct
40. Which Data Dictionary view can be used to display the detailed
code of a procedure in your schema? Mark for Review
(1) Points
USER_SUBPROGRAMS
USER_SOURCE (*)
None of these
USER_OBJECTS
USER_PROCEDURES
Correct Correct
Section 9
(Answer all questions in this section)
41. JOHN and FRED are database users. JOHN grants SELECT privilege to
FRED on three of his (JOHN's) tables. Which Dictionary view should FRED query to
see the names of JOHN's three tables? Mark for Review
(1) Points
FRED_TABLES
USER_TABLES
ALL_TABLES (*)
DICTIONARY
DBA_TABLES
Correct Correct
42. Which of the following will display how many objects of each type
are in a user's schema? Mark for Review
(1) Points
DESCRIBE user_objects
GROUP BY object_type;
SELECT COUNT(*)
FROM user_objects;
Correct Correct
The subprogram will fail because the PRAGMA statement must be before IS.
The subprogram will fail because it is missing AUTHID CURRENT_USER before IS.
Correct Correct
44. User SALLY's schema contains a NEWEMP table. Sally uses Invoker's
rights to create procedure GET_NEWEMP which includes the line:
SELECT ... FROM NEWEMP ... ;
Sally also grants EXECUTE privilege on the procedure to CURLY, but no other
privileges. What will happen when Curly executes the procedure?
The procedure will fail because Curly does not have SELECT privilege on
NEWEMP.
The procedure will fail because there is no NEWEMP table in Curly's schema.
(*)
The procedure will fail because Curly does not have the EXECUTE ANY PROCEDURE
system privilege.
Correct Correct
Correct Correct
Section 9
(Answer all questions in this section)
DECLARE
v_mynum NUMBER(6,2);
v_mydate DATE;
BEGIN
... Line A
END;
Which of the following would you include at Line A?
find_sal(100,v_mynum);
find_sal(v_mynum,100);
v_mydate := find_sal(100);
Correct Correct
RETURN (p_param > 10); is wrong because you cannot return an expression.
Correct Correct
RETURN BOOLEAN
An OUT parameter
Correct Correct
The data type for the tax variable does not match the data type for salary.
Correct Correct