You are on page 1of 10

1.

You want to take make a copy of all


the cities in the world listed in the Mark for Review
cities table, which contains millions (1) Points
of rows. The following procedure
accomplishes this efficiently. True
or False?

CREATE OR REPLACE PROCEDURE


copy_cities IS
TYPE t_cities IS TABLE OF
cities%ROWTYPE INDEX BY
BINARY_INTEGER;
v_citiestab t_emp;
BEGIN
SELECT * BULK COLLECT INTO
v_citiestab FROM cities;
FORALL i IN
v_citiestab.FIRST..v_citiestab.LAST
INSERT INTO new_cities VALUES
v_citiestab(i);
END copy_cities;

True (*)
False

Correct

2. FORALL can only be used with the INSERT statement.


True or False? Mark for Review
(1) Points

True
False (*)

Incorrect. Refer to Section


12 Lesson 2.

3. What are benefits of using the NOCOPY hint? (Choose


two) Mark for Review
(1) Points

(Choose all correct answers)

Efficient since it uses less memory (*)


Faster because a single copy of the data is used
(*)
Uses a larger block of server memory for faster
access
Safer because it uses passing by value
Incorrect. Refer to Section
12 Lesson 2.

4. The following procedure compiles successfully. True or


False? Mark for Review
(1) Points
CREATE OR REPLACE PACKAGE emp_pkg IS
TYPE t_emp IS TABLE OF employees%ROWTYPE
INDEX BY BINARY_INTEGER;
PROCEDURE emp_proc
(p_small_arg IN NUMBER, p_big_arg NOCOPY OUT
t_emp);
...
END emp_pkg;

True
False (*)

Incorrect. Refer to Section


12 Lesson 2.

5. FORALL can be used with any DML statement. True or


False? Mark for Review
(1) Points

True (*)
False

Correct
6. What is the
main Mark for Review
purpose for (1) Points
using the
RETURNING
clause?

Return more readily any exceptions that are raised by the statement
Improve performance by minimizing the number of statements
Improve performance by making one call to the SQL engine (*)
Improve performance by returning a single value

Correct

7. Which of the following are NOT benefits of using the NOCOPY hint? (Choose
two) Mark for Review
(1) Points

(Choose all correct answers)


Faster because a single copy of the data is used
Eliminates extra processing
Safer because it uses passing by value (*)
Efficient since it uses less memory
Uses a larger block of server memory for faster access (*)

Incorrect. Refer to Section 12 Lesson 2.

8. In the following example, where do you place the phrase BULK COLLECT?
Mark for Review
DECLARE (1) Points
TYPE NameList IS TABLE OF emp.ename%TYPE;
names NameList;
CURSOR c1 IS SELECT ename -- Position A
FROM emp WHERE job = 'CLERK';
BEGIN
OPEN c1;
FETCH c1 -- Position B
INTO -- Position C
names;
...
CLOSE c1;
END;

Position A
Position B (*)
Position C

Incorrect. Refer to Section 12 Lesson 2.

9. When SQL statements are included within a procedure, the statements are
parsed when the procedure is compiled. True or False? Mark for Review
(1) Points

True (*)
False

Correct

10. Which is the correct order for the execution flow of SQL?
Mark for Review
(1) Points

Parse
Fetch
Bind
Execute
Bind
Parse
Execute
Fetch
Parse
Bind
Execute
Fetch
(*)
Execute
Parse
Fetch
Bind

Incorrect. Refer to Section 12 Lesson 1.


11. The easiest
way to Mark for Review
include (1) Points
DDL
statements
in a
PL/SQL
block is to
use the
DBMS_SQL
package.
True or
False?

True
False (*)

Correct

12. For which of the following is it necessary to use Dynamic SQL? (Choose
three.) Mark for Review
(1) Points

(Choose all correct answers)

ALTER (*)
SAVEPOINT
GRANT (*)
DROP (*)
UPDATE

Incorrect. Refer to Section 12 Lesson 1.

13. Examine the following code:


Mark for Review
CREATE OR REPLACE PROCEDURE myproc IS (1) Points
CURSOR c_curs IS SELECT view_name FROM user_views;
BEGIN
FOR v_curs_rec IN c_curs LOOP
EXECUTE IMMEDIATE 'DROP VIEW ' || v_curs_rec.view_name;
END LOOP;
END;

What will happen when this procedure is invoked?

The procedure will raise an exception because one of the views is a


complex view.
All views in the user's schema will be dropped. (*)
The procedure will not compile successfully because the syntax of
EXECUTE IMMEDIATE is incorrect.
The procedure will raise an exception because Dynamic SQL can drop
tables but cannot drop views.

Incorrect. Refer to Section 12 Lesson 1.

14. Name two reasons for using Dynamic SQL.


Mark for Review
(1) Points

(Choose all correct answers)

Avoids errrors at compile time of DML statements


Enables data-definition statements to be written and executed from
PL/SQL (*)
Creates a SQL statement with varying column data, or different
conditions (*)
Enables system control statements to be written and executed from
PL/SQL

Incorrect. Refer to Section 12 Lesson 1.

15. Which of the following SQL statements can be included in a PL/SQL block only
by using Dynamic SQL? (Choose two.) Mark for Review
(1) Points

(Choose all correct answers)

SAVEPOINT
ALTER (*)
DELETE
GRANT (*)
SELECT ..... FOR UPDATE NOWAIT

Incorrect. Refer to Section 12 Lesson 1.


1. The
easiest Mark for Review
way to (1) Points
include
DDL
statements
in a
PL/SQL
block is to
use the
DBMS_SQL
package.
True or
False?

True
False (*)

Correct

2. The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE. True or


False? Mark for Review
(1) Points

True
False (*)

Incorrect. Refer to Section 12 Lesson 1.

3. For which of the following is it necessary to use Dynamic SQL? (Choose three.)
Mark for Review
(1) Points

(Choose all correct answers)

SAVEPOINT
ALTER (*)
DROP (*)
GRANT (*)
UPDATE

Correct

4. Which of the following SQL statements can be included in a PL/SQL block only
by using Dynamic SQL? (Choose two.) Mark for Review
(1) Points

(Choose all correct answers)

GRANT (*)
SAVEPOINT
DELETE
SELECT ..... FOR UPDATE NOWAIT
ALTER (*)

Correct

5. What happens when a SQL statement is parsed? (Choose three.)


Mark for Review
(1) Points

(Choose all correct answers)

The results of the statement are returned to the user.


The user's required privileges are checked. (*)
The syntax of the statement is checked. (*)
Oracle queries the Data Dictionary to make sure that the tables referenced
in the SQL statement exist. (*)
The statement is executed.

Incorrect. Refer to Section 12 Lesson 1.


6. Which is
the Mark for Review
correct (1) Points
order for
the
execution
flow of
SQL?

Parse
Fetch
Bind
Execute
Parse
Bind
Execute
Fetch
(*)
Bind
Parse
Execute
Fetch
Execute
Parse
Fetch
Bind

Correct
7. When SQL statements are included within a procedure, the statements are
parsed when the procedure is compiled. True or False? Mark for Review
(1) Points

True (*)
False

Correct

8. What are benefits of using the NOCOPY hint? (Choose two)


Mark for Review
(1) Points

(Choose all correct answers)

Uses a larger block of server memory for faster access


Faster because a single copy of the data is used (*)
Safer because it uses passing by value
Efficient since it uses less memory (*)

Correct

9. What are benefits of using the NOCOPY hint? (Choose two)


Mark for Review
(1) Points

(Choose all correct answers)

Uses a larger block of server memory for faster access


Safer because it uses passing by value
Efficient since it uses less memory (*)
Faster because a single copy of the data is used (*)

Correct

10. Which of the following are NOT benefits of using the NOCOPY hint? (Choose two)
Mark for Review
(1) Points

(Choose all correct answers)

Eliminates extra processing


Efficient since it uses less memory
Uses a larger block of server memory for faster access (*)
Faster because a single copy of the data is used
Safer because it uses passing by value (*)

Correct
11. To create a list
movies from a Mark for Review
catalog of millions (1) Points
of titles, you could
use the following
code statement to
create a collection.
True or False?

...
TYPE nametab IS
TABLE OF
movies.title%TYPE;
Title_tab
nametab;
...
SELECT title BULK
COLLECT INTO
title_tab FROM
movies ORDER BY
rental_count DESC;
...

True (*)
False

Correct

12. What is the main purpose for using the RETURNING clause?
Mark for Review
(1) Points

Improve performance by minimizing the number of statements


Improve performance by returning a single value
Return more readily any exceptions that are raised by the
statement
Improve performance by making one call to the SQL engine (*)

Correct

13. The following statement is a valid example of using the RETURNING


clause. True or False? Mark for Review
(1) Points
DECLARE
TYPE EmpRec IS RECORD (last_name
employees.last_name%TYPE, salary employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id
= emp_id
RETURNING last_name, salary INTO emp_info;
dbms_output.put_line('Just gave a raise to ' ||
emp_info.last_name ||
', who now makes ' || emp_info.salary);
END;

True (*)
False

Correct

14. FORALL can only be used with the INSERT statement. True or False?
Mark for Review
(1) Points

True
False (*)

Correct

15. What does the RETURNING clause do in the example below?


Mark for Review
CREATE OR REPLACE PROCEDURE new_dept (1) Points
(p_dept_name IN departments.name%TYPE) IS
v_new_dept_id departments.dept_id%TYPE;
BEGIN
INSERT INTO departments (dept_id, name)
VALUES dept_seq.NEXTVAL, p_dept_name
RETURNING dept_seq.CURRVAL INTO v_new_dept_id;
DBMS_OUTPUT.PUT_LINE(p_dept_name ||' is department number '
|| v_new_dept_id);
END new_dept;

Inserts the new department id in the department table


Uses the new department number in a cursor
Performs the SELECT statement to determine the department id
of the new department (*)

Incorrect. Refer to Section 12 Lesson 2.

You might also like