Sei sulla pagina 1di 48

Test: Creating Packages: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Which of the following can be included in a package?


Mark for Review
(1) Points

procedures

variables

PL/SQL types

Exceptions

All of the above (*)

Correct

2. Which of the following are good reasons to group a set of procedures and functions
into a package? Mark for Review
(1) Points

Application developers do not need to know the details of the package body
code.
Related subprograms and variables can be grouped together for easier
management and maintenance.
If the detailed code is changed, applications which invoke the package do not
need to be recompiled.
All of the above. (*)

Correct

3. In which component of a package is the full definition of a public procedure written?


Mark for Review
(1) Points

Body (*)

Specification

Both the body and the specification

Neither the body nor the specification

Correct

4. The two parts of a package are stored as separate objects in the database. True or
False? Mark for Review
(1) Points

True (*)

False
Correct

5. To be able to invoke a package subprogram from outside the package, it must be


declared in the package: Mark for Review
(1) Points

Body

Specification

Body and the specification (*)

None of the above

Correct

6. A number variable declared in a package is initialized to 0 unless assigned another


value. True or False? Mark for Review
(1) Points

True

False (*)

Correct

7. Package Specification DEPT_PACK was created by the following code:


Mark for Review
CREATE OR REPLACE PACKAGE dept_pack IS (1) Points
PROCEDURE ins_dept(p_deptno IN NUMBER);
FUNCTION get_dept(p_deptno IN NUMBER) RETURN VARCHAR2;
END dept_pack;

Which of the following are correct syntax for invoking the package subprograms?
(Choose two.)

(Choose all correct answers)

BEGIN
dept_pack.ins_dept(20);
END;

(*)
BEGIN
dept_pack.get_dept(20);
END;

DECLARE
v_deptname VARCHAR2(20);
BEGIN
v_deptname := get_dept(50);
END;

CREATE PROCEDURE dept_proc IS


v_deptname VARCHAR2(20);
BEGIN
v_deptname := dept_pack.get_dept(40);
END;
(*)
BEGIN
dept_pack(30);
END;

Correct

8. Package EMP_PACK contains two procedures, DEL_EMP and SHOW_EMP. You want
to write an anonymous block which invokes these procedures but you have Mark for Review
forgotten which parameters they use. Which of the following will give you this (1) Points
information?

DESCRIBE del_emp
DESCRIBE show_emp

DESCRIBE emp_pack(del_emp, show_emp)

DESCRIBE emp_pack

(*)
DESCRIBE emp_pack.del_emp
DESCRIBE emp_pack.show_emp

None of the above

Correct

Test: Managing Package Concepts: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. A public component declared in the package specification can be referenced by a


private component defined in the package body. True or False? Mark for Review
(1) Points

True (*)

False

Correct

2. A local variable declared within a procedure in a package can be referenced by any


other component of that package. True or False? Mark for Review
(1) Points
True

False (*)

Correct

3. Examine the following package specification:


Mark for Review
CREATE OR REPLACE PACKAGE mypack IS (1) Points
percent_tax NUMBER := 20;
PROCEDURE proc1;
END mypack;

The package body of mypack also includes a function called func1. Which of the
following statements are true? (Choose three.)

(Choose all correct answers)

proc1 is a public procedure and func1 is a private function.

(*)
The package will not compile because you cannot declare variables in the
specification, only procedures and functions. .

The variable can be modified by:

BEGIN
mypack.percent_tax := 10;
END;

(*)
The function can be invoked from outside the package.

The procedure can be invoked by:

BEGIN
mypack.proc1;
END;

(*)

Correct

4. We want to remove both the specification and the body of package CO_PACK from
the database. Which of the following commands will do this? Mark for Review
(1) Points

DROP BOTH co_pack;

DROP PACKAGE BODY co_pack;

DROP PACKAGE co_pack; (*)

DROP PACKAGE SPECIFICATION co_pack;

None of the above

Correct
5. Which one of the following queries would you use to see the detailed code of a
package called EMP_PKG? Mark for Review
(1) Points

SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type =


'PACKAGE' ORDER BY line;
SELECT source FROM user_packages WHERE name = 'EMP_PKG' AND type =
'PACKAGE BODY' ORDER BY line;
SELECT text FROM all_source WHERE name = 'EMP_PKG' AND type =
'PACKAGE' ORDER BY line;
SELECT text FROM user_source WHERE name = 'EMP_PKG' AND type =
'PACKAGE BODY' ORDER BY line; (*)

Correct

6. What will be displayed when a user executes the following statement?


Mark for Review
SELECT object_name FROM user_objects (0) Points
WHERE object_type LIKE 'PACK%';

The names of all package specifications in the user's schema

The names of all package specifications and package bodies in the user's
schema (*)
The parameters which must be used when invoking all packaged
subprograms in the user's schema
The detailed code of all packages in the user's schema

The names of all packages which can be invoked by the user

Correct

7. When one component of a package is called, all the package's components are
loaded into memory. True or False? Mark for Review
(1) Points

True (*)

False

Correct

8. A local variable defined inside a package procedure is visible to the calling


environment. True or False? Mark for Review
(1) Points

True

False (*)

Correct

9. Your schema contains a package called EMP_PKG. You want to remove the
package body but not the specification. The correct syntax to do this is: DROP Mark for Review
BODY emp_pkg; True or False? (1) Points

True
False (*)

Correct

10. SCOTT's schema contains a package EMP_PKG which contains a public procedure
EMP_SAL which accepts a NUMBER parameter. Which of the following will invoke Mark for Review
the procedure successfully? (0) Points

emp_pkg.emp_sal(101);

scott.emp_pkg.emp_sal(101): (*)

emp_sal(101);

None of the above

All of the above

Correct

Test: Advanced Package Concepts: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Which two of these functions could not be in the same package? 1. FUNCTION
get_emp (p1 DATE) RETURN VARCHAR2; 2. FUNCTION get_emp (p1 DATE, p2 Mark for Review
NUMBER) RETURN VARCHAR2; 3. FUNCTION get_emp (p1 DATE, p2 NUMBER) (1) Points
RETURN NUMBER; 4. FUNCTION get_emp (p1 NUMBER, p2 DATE) RETURN
VARCHAR2;

1 and 2

1 and 4

2 and 4

2 and 3 (*)

3 and 4

Correct

2. Examine the following package code:


Mark for Review
CREATE OR REPLACE PACKAGE over_pack IS (1) Points
PROCEDURE do_work1 (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE do_work2 (p1 IN VARCHAR2, p2 IN NUMBER);
PROCEDURE do_work1 (param1 IN CHAR, param2 IN NUMBER);
FUNCTION do_work2 (param1 IN VARCHAR2, param2 IN NUMBER) RETURN
DATE;
END over_pack;

Which of the following calls will be successful? (Choose three.)


(Choose all correct answers)

over_pack.do_work1('Smith',20);

v_date := over_pack.do_work2('Smith',20); (*)

over_pack.do_work2('Smith',20); (*)

over_pack.do_work1(p1=>'Smith',p2=>20); (*)

over_pack.do_work1(param1=>'Smith');

Correct

3. If a subprogram is public (declared in the package specification), its detailed code


can be written anywhere in the package body without the need to use forward Mark for Review
declarations. True or False? (1) Points

True (*)

False

Correct

4. A package initialization block is executed automatically every time a user invokes


any procedure or function in the package. True or False? Mark for Review
(1) Points

True

False (*)

Correct

5. Which one of the following is NOT a restriction on a package function called from a
SQL statement? Mark for Review
(1) Points

The function can include a COMMIT.

The function can be overloaded. (*)

The function can include a ROLLBACK.

The function can return a BOOLEAN.

Correct

6. The package name must be included when calling a package function from a
SELECT statement executed outside the package. True or False? Mark for Review
(1) Points

True (*)

False

Correct
7. Package FORWARD_PACK contains two procedures: PROC1 is public while PROC2
is private (not declared in the package specification). These procedures have no Mark for Review
parameters. Which of the following package bodies will NOT compile successfully? (1) Points
(Choose two.)

(Choose all correct answers)

CREATE OR REPLACE PACKAGE BODY forward_pack IS


PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Any message');
END;
END forward_pack;

(*)
CREATE OR REPLACE PACKAGE BODY forward_pack IS
PROCEDURE proc2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Any message');
END;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
END forward_pack;

CREATE OR REPLACE PACKAGE BODY forward_pack IS


PROCEDURE proc2;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Any message');
END;
END forward_pack;

CREATE OR REPLACE PACKAGE BODY forward_pack IS


PROCEDURE proc1;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
proc1;
END;
END forward_pack;

(*)
CREATE OR REPLACE PACKAGE BODY forward_pack IS
PROCEDURE proc2;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
BEGIN
proc1;
END;
END forward_pack;

Correct

8. Which of the following best describes a package initialization block?


Mark for Review
(1) Points

It is a named procedure in a package which must be invoked by a user before


any other part of the package can be invoked.
It is an anonymous block in the package specification.

It is an anonymous block at the end of a package body which executes


automatically the first time each user session invokes a subprogram in the
package. (*)
It is a private function within the package body.

Because it is an anonymous block, it cannot be invoked and therefore will


never execute. It is treated as a set of comments.

Correct

9. A bodiless package contains what?


Mark for Review
(1) Points

Procedures only

Functions only

Public variables only (*)

Private variables only

Correct

10. The following package is valid. True or False?


Mark for Review
CREATE OR REPLACE PACKAGE exceptions_pkg IS (1) Points
e_cons_violation EXCEPTION;
PRAGMA EXCEPTION_INIT (e_cons_violation, -2292);
e_value_too_large EXCEPTION;
PRAGMA EXCEPTION_INIT (e_value_too_large, -1438);
END exceptions_pkg;

True (*)

False

Correct

11. How would you invoke the constant km_to_mile from the global_consts bodiless
package at VARIABLE A? Mark for Review
(1) Points
SELECT trail_name, distance_in_km * VARIABLE A
FROM trails
WHERE park_name = 'YOSEMITE';
km_to_mile.global_consts

km_to_mile (global_consts)

global_consts.km_to_mile (*)

global_consts (km_to_mile)

Correct

12. When using a package function in DML statements, which rules must you follow?
(Choose three) Mark for Review
(1) Points

(Choose all correct answers)

Must not end the current transaction (*)

Can read or modify the table being changed by that DML statement

Changes to a package variable could have an impact on another stored


function (*)
Cannot execute a DML statement or modify the database (*)

Incorrect. Refer to Section 10 Lesson 3.

13. The following example package specification is valid to create a data type ed_type
that can be used in other subprograms. True or False? Mark for Review
(1) Points
CREATE OR REPLACE PACKAGE emp_dept_pkg
IS
TYPE ed_type IS RECORD (f_name employees.first_name%TYPE,
l_name employees.last_name%TYPE,
d_name departments.department_name%TYPE);
PROCEDURE sel_emp_dept
(p_emp_id IN employees.employee_id%TYPE,
p_emp_dept_rec OUT ed_type);
END emp_dept_pkg;

True (*)

False

Correct

14. INDEX BY is missing from the empt_tab TYPE declaration. What is the most
efficient declaration? Mark for Review
(1) Points
CREATE OR REPLACE PACKAGE emp_pkg IS
TYPE emp_tab IS TABLE OF employees%ROWTYPE;
PROCEDURE get_employees(p_emp_table OUT emp_tab);
END emp_pkg;

INDEX BY INTEGER

INDEX BY BINARY

INDEX BY BINARY_INTEGER (*)


INDEX ALL

Correct

Test: Persistant State of Package Variables: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. A package's state is initialized when the package is first loaded. True or False?
Mark for Review
(1) Points

True (*)

False

Correct

2. Users A and B call the same procedure in a package to initialize a global variable
my_pkg.g_var. What will be the value of my_pkg.g_var for User A at Point A? Mark for Review
(1) Points
User A: my_pkg.g_var is 10
User B: my_pkg.g_var is 10
User A: my_pkg.g_var is 50
User B: my_pkg.g_var is 25
Point A

10

50 (*)

25

Correct

3. A cursor's state is defined only by whether it is open or closed and, if open, how
many rows it holds. True or False? Mark for Review
(1) Points

True

False (*)

Correct

4. In the following example, which statement best fits in Line 1? (Choose 1)


Mark for Review
DECLARE (1) Points
v_more_rows_exist BOOLEAN := TRUE;
BEGIN
-- Line 1
LOOP
v_more_rows_exist := curs_pkg.fetch_n_rows(3);
DBMS_OUTPUT.PUT_LINE('-------');
EXIT WHEN NOT v_more_rows_exist;
END LOOP;
curs_pkg.close_curs;
END;

curs_pkg.emp_curs%ISOPEN;

curs_pkg.close_curs;

curs_pkg.open_curs; (*)

EXIT WHEN curs_pkg.emp_curs%NOTFOUND;

Correct

Test: Using Oracle-Supplied Packages: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. The DBMS_OUTPUT package is useful for which of the following activities? (Choose
two) Mark for Review
(1) Points

(Choose all correct answers)

Interact with a user during execution of a function or procedure

Display results to the developer during testing for debugging purposes (*)

Trace the code execution path for a function or procedure (*)

Write operating system text files to the user's screen

Correct

2. The DBMS_OUTPUT gives programmers an easy-to-use interface to see, for


instance, the current value of a loop counter, or whether or not a program reaches a Mark for Review
particular branch of an IF statement. (True or False?) (1) Points

True (*)

False

Correct

3. Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1?
(Choose one) IF v_bool1 AND NOT v_bool2 AND v_number < 25 THEN --Line 1 Mark for Review
ELSE ... END IF; DBMS_OUTPUT.NEW_LINE; (1) Points

DBMS_OUTPUT.PUT('IF branch was executed'); (*)

DBMS_OUTPUT.PUT_LINE('IF branch was executed');

DBMS_OUTPUT.GET_LINE('IF branch was executed');

DBMS_OUTPUT.NEW_LINE('IF branch was executed');

Correct

4. The UTL_FILE package can be used to read and write binary files such as JPEGs as
well as text files. True or False? Mark for Review
(1) Points

True

False (*)

Correct

5. Using the FOPEN function, you can do which actions with the UTL_FILE package?
(Choose 2) Mark for Review
(1) Points

(Choose all correct answers)

It is used to append to a file until processing is complete. (*)

It is used to read and write text files stored outside the database. (*)

It is used to find out how much free space is left on an operating system disk.

It is used to manipulate large object data type items in columns.

Correct

6. The UTL_FILE package contains several exceptions exclusively used in this package.
Which are they? (Choose 3) Mark for Review
(1) Points

(Choose all correct answers)

INVALID_PATH (*)

NO_DATA_FOUND

WRITE_ERROR (*)

INVALID_OPERATION (*)

ZERO_DIVIDE

Correct

7. Which general exceptions may be handled by the UTL_FILE package? (Choose 2)


Mark for Review
(1) Points
(Choose all correct answers)

TOO_MANY_ROWS

VALUE_ERROR (*)

ZERO_DIVIDE

NO_DATA_FOUND (*)

Correct

Test: Using Dynamic SQL: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

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


Mark for Review
(1) Points

(Choose all correct answers)

The user's required privileges are checked. (*)

The syntax of the statement is checked. (*)

The statement is executed.

The results of the statement are returned to the user.

Oracle queries the Data Dictionary to make sure that the tables referenced in
the SQL statement exist. (*)

Correct

2. 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

3. A programmer wants to code a procedure which will create a table with a single
column. The datatype of the column will be chosen by the user who invokes the Mark for Review
procedure. The programmer writes the following code: (1) Points

CREATE OR REPLACE PROCEDURE create_tab


(p_col_datatype IN VARCHAR2) IS
BEGIN
CREATE TABLE newtab (only_col p_col_datatype);
END;

Why will this procedure not compile successfully?

Because you cannot create a table inside a procedure

Because the invoking user may not have CREATE TABLE privilege

Because when the procedure is compiled, Oracle cannot check if the parameter
value passed into the procedure is a valid column datatype (*)
Because table NEWTAB may already exist

None of the above; the procedure will compile successfully.

Correct

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

(Choose all correct answers)

ALTER (*)

GRANT (*)

SAVEPOINT

UPDATE

DROP (*)

Correct

5. Examine the following procedure, which drops a table whose name is passed as an
IN parameter: Mark for Review
(1) Points
CREATE OR REPLACE PROCEDURE drop_tab
(p_table_name IN VARCHAR2) IS
v_sql_statement VARCHAR2(100);
BEGIN
...
END;

Which of the following will work correctly when coded in the procedure's executable
section? (Choose two.)

(Choose all correct answers)

EXECUTE IMMEDIATE 'DROP TABLE p_table_name';

EXECUTE IMMEDIATE 'DROP TABLE ' || p_table_name;

(*)
v_sql_statement := 'DROP TABLE ' || p_table_name;
EXECUTE IMMEDIATE v_sql_statement;

(*)
v_sql_statement := 'DROP TABLE ' || p_table_name;
EXECUTE IMMEDIATE 'v_sql_statement';

v_sql_statement := 'DROP TABLE ';


EXECUTE IMMEDIATE v_sql_statement p_table_name;

Correct

6. What will happen when the following procedure is invoked?


Mark for Review
CREATE OR REPLACE PROCEDURE do_some_work IS (1) Points
CURSOR c_curs IS SELECT object_name FROM user_objects
WHERE object_type = 'FUNCTION';
BEGIN
FOR v_curs_rec IN c_curs LOOP
EXECUTE IMMEDIATE 'ALTER FUNCTION ' || v_curs_rec.object_name || '
COMPILE';
EXIT WHEN c_curs%ROWCOUNT > 2;
END LOOP;
END;

All functions in the user's schema will be recompiled.

The first two functions in the user's schema will be recompiled.

The first three functions in the user's schema will be recompiled. (*)

The procedure will not compile successfully because you cannot ALTER
functions using Dynamic SQL.
The procedure will not compile successfully because the syntax of the ALTER
FUNCTION statement is incorrect.

Correct

7. The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE. True or False?
Mark for Review
(1) Points

True

False (*)

Correct

8. Only one call to DBMS_SQL is needed in order to drop a table. True or False?
Mark for Review
(1) Points

True

False (*)

Correct

9. Name two reasons for using Dynamic SQL.


Mark for Review
(1) Points
(Choose all correct answers)

Avoids errrors at compile time of DML statements

Creates a SQL statement with varying column data, or different conditions (*)

Enables data-definition statements to be written and executed from PL/SQL (*)

Enables system control statements to be written and executed from PL/SQL

Correct

Test: Improving PL/SQL Performance: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

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


Mark for Review
(1) Points

(Choose all correct answers)

Safer because it uses passing by value

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 (*)

Correct

2. A function-based index may be made using your own functions, but only if the
function is created using the DETERMINISTIC clause. True or False? Mark for Review
(1) Points

True (*)

False

Correct

3. The following procedure compiles successfully. True or False?


Mark for Review
CREATE OR REPLACE PACKAGE emp_pkg IS (1) Points
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 (*)

Correct

4. In the following example, where do you place the phrase DETERMINISTIC?


Mark for Review
CREATE OR REPLACE FUNCTION total_sal (1) Points
(p_dept_id IN -- Position A
employees.department_id%TYPE)
RETURN NUMBER -- Position B
IS v_total_sal NUMBER;
BEGIN
SELECT SUM(salary) INTO v_total_sal
FROM employees WHERE department_id = p_dept_in;
RETURN v_total_sal -- Position C;
END total_sal;

Position A

Position B (*)

Position C

Correct

5. What is wrong with this code example?


Mark for Review
CREATE OR REPLACE PROCEDURE insert_emps IS (1) Points
TYPE t_emp IS TABLE OF employees%ROWTYPE INDEX BY BINARY_INTEGER;
v_emptab t_emp;
BEGIN
FORALL i IN v_emptab.FIRST..v_emptab.LAST
INSERT INTO employees VALUES v_emptab(i);
END LOOP;
END insert_emps;

The phrase should be FOR ALL.

v_emptab is incorrectly typed.

FORALL does not require END LOOP. (*)

Nothing is wrong; it will compile successfully.

Correct

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

True

False (*)

Correct
7. In the following example, where do you place the phrase BULK COLLECT?
Mark for Review
... (1) Points
BEGIN
SELECT -- Position A
salary -- Position B
INTO v_saltab -- Position C
FROM employees WHERE department_id = 20 ORDER BY salary
-- Position D
;
...

Position A

Position B (*)

Position C

Position D

Correct

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

Correct

9. What is the main purpose for using the RETURNING clause?


Mark for Review
(1) Points

Improve performance by returning a single value

Improve performance by minimizing the number of statements

Improve performance by making one call to the SQL engine (*)

Return more readily any exceptions that are raised by the statement

Correct
10. 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

Test: Introduction to Triggers: Quiz

Answer the question(s) on this page, and click Next to go to the next test page. Click Summary to see which
questions you need to answer before submitting the test. Click Finish Test if you are ready to submit your test.

Section 1
(Answer all questions in this section)

1. Which of the following could NOT be done by a database trigger?


Mark for Review
(1) Points

Enforcing a complex business rule

Enforcing a complex database security check

Recalculating the total salary bill for a department whenever an employee's


salary is changed
Ensuring that a student never arrives late for a class

Keeping a log of how many rows have been inserted into a table

2. You can use a database trigger to prevent invalid transactions from being
committed. True or False? Mark for Review
(1) Points

True

False

3. Which of the following best describes a database trigger?


Mark for Review
(1) Points

It allows users to log on to the database.

It executes automatically whenever a particular event occurs within the


database.
It prevents unique constraints from being violated.

It executes automatically whenever a user clicks on a button with his mouse.

It allows foreign key constraints to be violated.

4. A database trigger is a PL/SQL stored subprogram which is explicitly invoked just


like a procedure or a function. True or False? Mark for Review
(1) Points

True

False

5. Which of the following events could NOT automatically fire a database trigger?
Mark for Review
(1) Points

A user logging on to the database

A SQL INSERT statement

You click your mouse on a button to choose the correct answer to this
question
A DML operation on a view

The Database Administrator shuts down the database

6. While editing a document in Microsoft Word, you go to the FILE menu and SAVE
your work. To do this, Microsoft Word has executed an application trigger. True or Mark for Review
False? (1) Points

True

False

7. A business rule states that an employee's salary must be between 4000 and
30000. We could enforce this rule using a check constraint, but it is better to use a Mark for Review
database trigger. True or False? (1) Points

True

False

8. Which of the following are good guidelines to follow when creating triggers?
(Choose two) Mark for Review
(1) Points

(Choose all correct answers)

Be aware of recursive and cascading effects

Where possible, use triggers to enforce NOT NULL constraints

Avoid lengthy trigger logic by creating a procedure and invoking it from within
the trigger
Use triggers to replace functionality which is already built into the database

Always create more triggers than you need, because it is better to be safe
9. A user's schema contains procedure MYPROC, function MYFUNC, trigger MYTRIGG
and package MYPACK which contains a public procedure PACKPROC. These Mark for Review
subprograms have no parameters, and the function returns a NUMBER. Which of (1) Points
the following calls to these objects (from an anonymous block) are incorrect?
(Choose two)

(Choose all correct answers)

mypack.packproc;

mytrigg;

myproc;

v_number := myfunc;

IF NOT myfunc THEN ...

10. Which of the following are NOT allowed within a database trigger? (Choose two)
Mark for Review
(1) Points

(Choose all correct answers)

COMMIT

A call to a packaged procedure

INSERT

A Boolean variable

SAVEPOINT

Test: Creating DML Triggers: Part I: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Which of the following is the correct syntax for creating a DML trigger associated
with the EMPLOYEES table? The trigger must fire whenever an employee's JOB_ID is Mark for Review
updated, but not if a different column is updated. (1) Points

CREATE TRIGGER job_upd_trigg


AFTER UPDATE ON employees(job_id)
BEGIN ...

CREATE TRIGGER job_upd_trigg


WHENEVER UPDATE OF job_id IN employees
BEGIN ...

CREATE TRIGGER job_upd_trigg


AFTER UPDATE ON employees.job_id
BEGIN ...
CREATE TRIGGER job_upd_trigg
AFTER UPDATE OF job_id ON employees
BEGIN ...

(*)

Correct

2. What is wrong with the following code?


Mark for Review
CREATE OR REPLACE TRIGGER mytrigg (1) Points
AFTER DELETE ON departments
BEGIN
INSERT INTO audit_table (who, when)
VALUES (USER, SYSDATE);
COMMIT;
END;

A DML trigger cannot itself contain a DML statement such as INSERT INTO
audit_table.
You cannot use COMMIT inside a trigger. (*)

The last line of code should be END mytrigg;

The second line should be: AFTER DELETE OF DEPARTMENTS

Nothing is wrong, the trigger will execute successfully.

Correct

3. Which of the following are possible keywords for the timing component of a trigger?
(Choose three.) Mark for Review
(1) Points

(Choose all correct answers)

BEFORE (*)

INSTEAD

WHENEVER

INSTEAD OF (*)

AFTER (*)

Correct

4. We want to create a log record automatically every time any DML operation is
executed on either or both of the EMPLOYEES and DEPARTMENTS tables. What is Mark for Review
the smallest number of triggers that must be create to do this? (1) Points

One

Two (*)

Three

Six

Eight
Correct

5. We want to prevent employees from being deleted on Sundays. To do this, we


create the following trigger: Mark for Review
(1) Points
CREATE OR REPLACE TRIGGER stop_del_emps
....... DELETE ON employees -- Line A
BEGIN
IF TO_CHAR(SYSDATE','DY') = 'SUN' THEN
RAISE_APPLICATION_ERROR(-20101,'Invalid delete');
END IF;
END;

Should this be a BEFORE or AFTER trigger, and why?

It should be a BEFORE trigger because if an AFTER trigger were created, the


employee would already have been deleted by the time the trigger checks the
date. (*)
It should be a BEFORE trigger because you cannot use
RAISE_APPLICATION_ERROR with AFTER triggers.
It should be an AFTER trigger because the Oracle Server cannot fire the trigger
until it knows that the employee has been deleted.
It does not matter, either a BEFORE or an AFTER trigger could be created.

Correct

6. An AFTER UPDATE trigger can specify more than one column. True or False?
Mark for Review
(1) Points

True (*)

False

Correct

7. A BEFORE statement trigger inserts a row into a logging table every time a user
updates the salary column of the employees table. The user now tries to update the Mark for Review
salaries of three employees with a single UPDATE statement, but the update fails (1) Points
because it violates a check constraint. How many rows will be inserted into the
logging table?

None, the transactions are rolled back because the update failed. (*)

One

Three

Four

None of the above

Correct

8. There are five employees in department 50. A statement trigger is created by:
Mark for Review
CREATE OR REPLACE TRIGGER emp_upd_trigg (1) Points
AFTER DELETE ON EMPLOYEES
BEGIN ...

A user now executes:


DELETE FROM employees WHERE department_id = 50;

How many times will the trigger fire, and when?

Once, before the DELETE is executed

Five times, after each employee row is deleted

Once, after the DELETE is executed (*)

Six times, once after each row and once at the end of the statement

The trigger will not fire at all.

Correct

Test: Creating DML Triggers: Part II: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. You decide to create the following trigger:


Mark for Review
CREATE OR REPLACE TRIGGER empl_trigg (1) Points
BEFORE UPDATE ON employees
BEGIN
-- Line A
RAISE_APPLICATION_ERROR('Cannot update salary');
ELSE
INSERT INTO log_table values (USER, SYSDATE);
END IF;
END;

You want the trigger to prevent updates to the SALARY column, but allow updates
to all other columns. What should you code at Line A?

IF UPDATING SALARY THEN

IF UPDATING('SALARY') THEN (*)

IF UPDATE('SALARY') THEN

IF UPDATING(SALARY) THEN

IF UPDATE(SALARY) THEN

Correct

2. Which of the following best describes conditional predicates in a trigger?


Mark for Review
(1) Points
They are special variables which must be DECLAREd within the trigger.

They allow the trigger code to see what data values are being inserted into a
row.
They are automatically declared boolean variables which allow the trigger
body to detect which DML operation is being executed. (*)
They are special cursor attributes, like %ROWCOUNT and %NOTFOUND

Correct

3. Examine the following code. To create a row trigger, what code should be included
at Line A? Mark for Review
(1) Points
CREATE OR REPLACE TRIGGER del_emp_trigg
BEFORE DELETE ON employees
---- Line A
BEGIN ...

FOR EVERY ROW

FOR EACH ROW (*)


FOR EVERY ROW

FOR ALL ROWS

Nothing is needed because DML triggers are row triggers by default.

Correct

4. A row trigger has been created which is fired by UPDATE ON employees. A user
now executes a single SQL statement which updates four rows of the EMPLOYEES Mark for Review
table. How many times will the row trigger fire? (1) Points

One time

Two times

Four times (*)

Five times

Eight times

Correct

5. Whenever an employee's JOB_ID is updated, we want to insert a row into a


logging table to record the employee_id and the new value of JOB_ID. We create a Mark for Review
row trigger whose body includes the following code: (1) Points

BEGIN
INSERT INTO logging_table (emp_id, job_id)
VALUES -- Point A
END;

At point A, which of the following will insert the correct data into the logging table?
(Choose two.)

(Choose all correct answers)


(:OLD.employee_id, :OLD.job_id);

(:OLD.employee_id, :NEW.job_id); (*)

(:NEW.employee_id, :OLD.job_id);

(:NEW.employee_id, :NEW.job_id); (*)

(NEW.employee_id, NEW.job_id);

Correct

6. The OLD and NEW qualifiers can be used with statement triggers as well as row
triggers. True or False? Mark for Review
(1) Points

True

False (*)

Correct

7. Which of the following statements about INSTEAD OF triggers are NOT true?
(Choose two.) Mark for Review
(1) Points

(Choose all correct answers)

They can be created on a table. (*)

They can be created on a simple view.

They can be created on a complex view.

They can be statement triggers. (*)

They can be row triggers.

Correct

8. The following view and trigger have been created:


Mark for Review
CREATE VIEW dept_view AS SELECT * FROM departments; (1) Points
CREATE OR REPLACE TRIGGER dept_view_trigg
INSTEAD OF UPDATE ON dept_view
BEGIN
DBMS_OUTPUT.PUT_LINE('Sample Message');
END;

Departments 50 and 80 exist but department 81 does not. A user now executes
the following statement:

UPDATE dept_view SET department_name = 'Sales'


WHERE department_id IN (50,80,81);

What happens?

Two rows are updated and "Sample Message" is displayed once.


No rows are updated and "Sample Message" is displayed once.

No rows are updated and "Sample Message" is displayed twice. (*)

No rows are updated and "Sample Message" is displayed three times.

None of the above

Correct

9. What are the timing events for a compound trigger?


Mark for Review
(1) Points

Before the triggering statement; After the triggering statement; Instead of the
triggering statement
Before the triggering statement; Before each row; After each row; After the
triggering statement (*)
Before the triggering statement; After the triggering statement; After each
row
Before the triggering statement; Before each row; After the triggering
statement

Correct

10. What is wrong with this compound trigger example?


Mark for Review
CREATE OR REPLACE TRIGGER compound_trigger (1) Points
FOR UPDATE OF salary
COMPOUND TRIGGER
threshold CONSTANT SIMPLE_INTEGER := 200;

BEFORE EACH ROW IS


BEGIN
-- some action
END BEFORE EACH ROW;

AFTER EACH ROW IS


BEGIN
-- some action
END AFTER EACH ROW;

AFTER STATEMENT IS
BEGIN
-- some action
END AFTER STATEMENT;
END compound_trigger;

Missing BEFORE timing statement

Missing the EXCEPTION section

Missing name of table on which the trigger fires (*)

Missing the INSTEAD OF timing section

Missing the BEFORE and INSTEAD OF timing sections

Correct
Test: Creating DDL and Database Events Triggers: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Which of the following could NOT cause a DDL or Database Event trigger to fire?
Mark for Review
(1) Points

A table is dropped.

A user connects to the database.

The DBA starts up the database.

A user deletes rows from the EMPLOYEES table. (*)

A specific exception is raised in a user's session.

Correct

2. The database administrator creates a trigger that automatically disconnects user


HACKER whenever HACKER connects to the database. What type of trigger is this? Mark for Review
(1) Points

A DDL trigger

A Database Event trigger (*)

A DML trigger

A statement trigger

An INSTEAD OF trigger

Correct

3. User HARJIT wants to prevent any objects which he owns from being dropped.
Harjit decides to execute the following code: Mark for Review
(1) Points
CREATE OR REPLACE TRIGGER stop_drop
---- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20201,'Attempted drop');
END;
What should Harjit code at Line A?

BEFORE DROP ON HARJIT

BEFORE DROP ON TABLE

BEFORE DROP ON SCHEMA (*)

BEFORE DROP ON OWNER

BEFORE DROP ON USER_OBJECTS

Correct
4. You can create a trigger which prevents DDL statements on an individual table,
while still allowing DDL on other tables in the same schema. True or False? Mark for Review
(1) Points

True

False (*)

Correct

5. The database administrator wants to write a log record every time any user's
session raises an ORA-00942 exception. The DBA decides to create the following Mark for Review
trigger: (1) Points

CREATE OR REPLACE TRIGGER log_942_trigg


AFTER SERVERERROR ON DATABASE
BEGIN
-- Line A
INSERT INTO log_table VALUES ( ...);
END;
What should the DBA code at Line A?

IF (SERVERERROR(942)) THEN

IF (IS_SERVERERROR(942)) THEN (*)

IF (SERVERERROR = 942) THEN

IF (IS_SERVERERROR = 942) THEN

IF (IS_SERVERERROR(ORA-00942)) THEN

Correct

6. What is the benefit of using the CALL statement in a trigger body?


Mark for Review
(1) Points

It allow both DDL events and database events to be handled by a single


trigger.
It prevents data being read from a mutating table.

It allows the database administrator to monitor who is currently connected to


the database.
It allows the trigger body code to be placed in a separate procedure. (*)

Correct

7. What is wrong with the following code?


Mark for Review
CREATE OR REPLACE TRIGGER call_trigg (1) Points
AFTER UPDATE OR DELETE ON employees
BEGIN
CALL del_emp_proc
END;

When CALL is used, the BEGIN and END; statements should be omitted. (*)

The CALL statement should end with a semicolon (;)

You cannot use a CALL statement in a DML trigger.


When using CALL, only one DML statement can be tested, so UPDATE OR
DELETE is wrong.

Correct

8. What is wrong with the following code?


Mark for Review
CREATE OR REPLACE TRIGGER emp_dml_trigg (1) Points
BEFORE UPDATE OF salary ON employees
FOR EACH ROW
DECLARE
v_max_sal employees.salary%TYPE;
BEGIN
SELECT max(sal) INTO v_max_sal FROM employees;
END;

You cannot use a DECLARE statement in a trigger.

The trigger body is reading the same table (employees) that the triggering
event is updating. (*)
You must use RAISE_APPLICATION_ERROR in a BEFORE trigger.

You can never use SELECT inside a DML trigger.

Nothing is wrong, the trigger will execute correctly.

Correct

9. Mutating table errors can be caused by DML triggers, but not by database event
triggers. True or False? Mark for Review
(1) Points

True (*)

False

Correct

10. You have been granted CREATE TRIGGER privilege. You can now create an AFTER
LOGOFF ON SCHEMA trigger. True or False? Mark for Review
(1) Points

True

False (*)

Correct

Test: Managing Triggers: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Which dictionary view would you query to see the detailed body code of triggers in
your schema? Mark for Review
(1) Points

USER_SOURCE

USER_TRIGGER

USER_TRIGGERS (*)

USER_OBJECTS

None of the above; you cannot view the code of the trigger body after the
trigger has been created.

Correct

2. By default, any user can create a DML trigger on a table in his/her schema. True or
False? Mark for Review
(1) Points

True

False (*)

Correct

3. You have created several DML triggers which reference your DEPARTMENTS table.
Now you want to disable all of them using a single SQL statement. Which command Mark for Review
should you use? (1) Points

ALTER TRIGGER DISABLE ALL ON departments;

ALTER TABLE departments DISABLE ALL TRIGGERS; (*)

ALTER TABLE departments DISABLE TRIGGERS;

DROP ALL TRIGGERS ON departments;

Correct

4. Which command would you use to see if your triggers are enabled or disabled?
Mark for Review
(1) Points

SELECT trigger_name, status


FROM USER_TRIGGERS;

(*)
SELECT object_name, status
FROM USER_OBJECTS
WHERE object_type = 'TRIGGER';

SELECT trigger_name, trigger_type


FROM USER_TRIGGERS;

DESCRIBE TRIGGER

Correct
5. User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG, which are
both DML triggers referencing her EMPLOYEES table. Kuljit now wants to remove Mark for Review
both of these triggers from the database. What command(s) should Kuljit use to do (1) Points
this?

DROP ALL TRIGGERS ON employees;

DROP TRIGGERS ON employees;

DROP TRIGGER emp1_trigg;


DROP TRIGGER emp2_trigg;

(*)
DROP TRIGGER emp1_trigg AND emp2_trigg;

Correct

6. A user creates the following trigger:


Mark for Review
CREATE OR REPLACE TRIGGER emp_trigg (1) Points
AFTER DELETE ON employees
BEGIN
...
END;

The user now tries to drop the EMPLOYEES table. What happens?

The table is dropped but the trigger is not dropped.

An error message is displayed because you cannot drop a table that is


referenced by a trigger.
The table is dropped and the trigger is disabled.

Both the table and the trigger are dropped. (*)

Correct

Test: Introduction to Dependencies: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. PL/SQL procedure A invokes procedure B, which in turn invokes procedure C,


which references table T. If table T is dropped, which of the following statements Mark for Review
is true? (1) Points

C is invalid but A and B are still valid


A, B and C are all invalid (*)

B and C are invalid but A is still valid

A, B and C are all still valid

None of the above

Correct

2. A procedure show_emps contains the following declaration:


CURSOR emp_curs IS SELECT last_name, salary FROM employees; Mark for Review
(1) Points
What will happen to the procedure if a new column is added to the employees
table?

The procedure will still be valid and execute correctly because it does not
reference the added column.
The procedure will automatically be dropped and must be recreated.

The procedure will be marked invalid and must be recompiled before it can be
reexecuted. (*)
Users' privileges to execute the procedure will automatically be revoked.

Correct

3. View dept_view is based on a select from table departments. Procedure show_dept


contains code which selects from dept_view. Which of the following statements are Mark for Review
true? (Choose three.) (1) Points

(Choose all correct answers)

departments is indirectly dependent on show_dept

show_dept is directly dependent on dept_view (*)

dept_view is directly dependent on departments (*)

show_dept is indirectly dependent on departments (*)

emp_view is directly dependent on show_dept

Correct

4. A single PL/SQL subprogram such as a procedure can be both a referenced object


and a dependent object. True or False? Mark for Review
(1) Points

True (*)

False

Correct

5. Which data dictionary view shows information about references and dependencies?
Mark for Review
(1) Points

DEPTREE
USER_DEPENDENCIES (*)

USER_REFERENCES

USER_LOCAL_DEPENDENCIES

Correct

6. Which of the following statements will show whether procedure myproc is valid or
invalid? Mark for Review
(1) Points

SELECT status FROM USER_OBJECTS


WHERE object_type = 'PROCEDURE'
AND object_name = 'MYPROC';

(*)
SELECT status FROM USER_PROCEDURES
WHERE procedure_name = 'MYPROC';

SELECT valid FROM USER_OBJECTS


WHERE object_type = 'PROCEDURE'
AND object_name = 'MYPROC';

SELECT * FROM deptree;

Correct

7. Which of the following database objects are created when the utldtree.sql script is
run? (Choose three.) Mark for Review
(1) Points

(Choose all correct answers)

The utldtree table

The deptree_temptab table (*)

The deptree and ideptree views (*)

The deptree table

The deptree_fill procedure (*)

Correct

8. User ALICE owns a procedure show_emps which references table employees.


Which of the following will generate information that shows this dependency? Mark for Review
(1) Points

BEGIN deptree_fill('TABLE','EMPLOYEES');
END;

BEGIN deptree_fill('PROCEDURE','ALICE','SHOW_EMPS');
END;

BEGIN deptree_fill('ALICE','TABLE','EMPLOYEES');
END;
BEGIN deptree_fill('TABLE','ALICE','EMPLOYEES');
END;

(*)
BEGIN deptree_fill('ALICE','PROCEDURE','SHOW_EMPS');
END;

Correct

9. A SELECT from DEPTREE produced the following output.


Mark for Review
>NESTED_LEVEL >TYPE >NAME (1) Points
>0 >TABLE >EMPLOYEES
>1 >VIEW >EMP_VW
>2 >PROCEDURE >ADD_EMP
>1 >PROCEDURE >QUERY_EMP

What dependencies does this show? (Choose three.)

(Choose all correct answers)

QUERY_EMP is directly dependent on EMPLOYEES (*)

ADD_EMP is directly dependent on EMPLOYEES

ADD_EMP is directly dependent on EMP_VW (*)

QUERY_EMP is directly dependent on ADD_EMP

EMP_VW is directly dependent on EMPLOYEES (*)

Incorrect. Refer to Section 14 Lesson 1.

10. The IDEPTREE view shows dependencies by indenting the lines of output instead
of by using a NESTED_LEVEL column. True or False? Mark for Review
(1) Points

True (*)

False

Correct

11. Procedure get_depts has been marked invalid because one of the objects it
references has been altered. Which of the following statements are true? (Choose Mark for Review
two.) (1) Points

(Choose all correct answers)

The procedure will be recompiled automatically the next time it is invoked.


The recompilation will always be successful.

The procedure will be recompiled automatically the next time it is invoked.


The recompilation may or may not be successful.
(*)
The procedure can be recompiled manually by:
ALTER PROCEDURE get_depts COMPILE;

(*)
The procedure can be recompiled manually by:
ALTER PROCEDURE get_depts RECOMPILE;

The procedure does not need to be recompiled.

Correct

12. A procedure includes the following code:


Mark for Review
SELECT first_name, salary INTO v_first_name, v_salary (1) Points
FROM employees WHERE employee_id = 100;

Which of the following changes to the employees table will allow the procedure to
be recompiled successfully ? (Choose two.)

(Choose all correct answers)

The table is dropped but a public table exists with the same name and
structure. (*)
The table is dropped.

A new column is added to the table. (*)

The table name is changed to newemps.

The first_name column is dropped from the table.

Correct

13. Which of the following will NOT help to minimize dependency failures? (Choose
two.) Mark for Review
(1) Points

(Choose all correct answers)

SELECTing a list of column names instead of using SELECT * (*)

Declaring records using the %ROWTYPE attribute

Including a column list with INSERT statements

Declaring scalar variables with NOT NULL if the corresponding table column
has a NOT NULL constraint (*)
Declaring scalar variables using the %TYPE attribute

Correct

14. Package emp_pack contains two public procedures: get_emps and upd_emps. A
separate procedure emp_proc invokes emp.pack.get_emps. The upd_emps Mark for Review
package body code is now altered, and the package body (but not the package (1) Points
specification) is recreated.
emp_proc will be marked invalid and needs to be recompiled. True or False?

True

False (*)

Correct

Test: Understanding Remote Dependencies: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. A remote dependency is when a dependent object resides on a database on a


separate node. True or False? Mark for Review
(1) Points

True (*)

False

Correct

2. With remote dependencies, one master data dictionary that resides on one server
identifies the status of all schema objects. True or False? Mark for Review
(1) Points

True

False (*)

Correct

3. The Data Dictionary controls the remote dependency mode. True or False?
Mark for Review
(1) Points

True

False (*)

Correct

4. Which statement for setting a database parameter is the default for remote
dependency checking? Mark for Review
(1) Points

ALTER SESSION SET REMOTE_DEPENDENCIES_MODE = TIMESTAMP (*)

ALTER SESSION SET REMOTE_DEPENDENCIES_MODE = SIGNATURE

ALTER SESSION REMOTE_DEPENDENCIES_MODE = TIMESTAMP


ALTER SESSION REMOTE_DEPENDENCIES_MODE = SIGNATURE

Correct

5. In this scenario, the following status is given for each procedure:


Mark for Review
- Procedure A is local and has a time stamp of 10 AM (1) Points
- Procedure B is remote and has a local time stamp of 5 AM and has a remote time
stamp of 4 AM

In Timestamp Mode, Procedure A will execute successfully at 11 AM. True or


False?

True

False (*)

Correct

6. In Signature Mode, a procedure will not compile if the signatures of the remote
dependencies do not match. True or False? Mark for Review
(1) Points

True (*)

False

Correct

7. In this scenario, the following status is given for each procedure:


Mark for Review
- Procedure A is local, executed, and invalidated because the remote Procedure B (1) Points
time stamp does not match the local time stamp for Procedure B
- Procedure A is recompiled.

In Timestamp Mode, now Procedure A will execute successfully. True or False?

True (*)

False

Correct

8. In Signature Mode, a compiled procedure is still valid if its dependent procedure


has a parameter data type change from NUMBER to VARCHAR2. Mark for Review
(1) Points

True

False (*)

Incorrect. Refer to Section 14 Lesson 2.

9. A remote dependency is when a dependent object resides on a database on a


separate node. True or False? Mark for Review
(1) Points
True (*)

False

Correct

10. With remote dependencies, one master data dictionary that resides on one server
identifies the status of all schema objects. True or False? Mark for Review
(1) Points

True

False (*)

Correct

11. The Data Dictionary controls the remote dependency mode. True or False?
Mark for Review
(1) Points

True

False (*)

Correct

12. Which statement for setting a database parameter is the default for remote
dependency checking? Mark for Review
(1) Points

ALTER SESSION SET REMOTE_DEPENDENCIES_MODE = TIMESTAMP (*)

ALTER SESSION SET REMOTE_DEPENDENCIES_MODE = SIGNATURE

ALTER SESSION REMOTE_DEPENDENCIES_MODE = TIMESTAMP

ALTER SESSION REMOTE_DEPENDENCIES_MODE = SIGNATURE

Correct

13. In this scenario, the following status is given for each procedure:
Mark for Review
- Procedure A is local and has a time stamp of 10 AM (1) Points
- Procedure B is remote and has a local time stamp of 5 AM and has a remote time
stamp of 4 AM

In Timestamp Mode, Procedure A will execute successfully at 11 AM. True or


False?

True

False (*)

Correct
14. In Signature Mode, a procedure will not compile if the signatures of the remote
dependencies do not match. True or False? Mark for Review
(1) Points

True (*)

False

Correct

15. In this scenario, the following status is given for each procedure:
Mark for Review
- Procedure A is local, executed, and invalidated because the remote Procedure B (1) Points
time stamp does not match the local time stamp for Procedure B
- Procedure A is recompiled.

In Timestamp Mode, now Procedure A will execute successfully. True or False?

True (*)

False

Incorrect. Refer to Section 14 Lesson 2.

16. In Signature Mode, a compiled procedure is still valid if its dependent procedure
has a parameter data type change from NUMBER to VARCHAR2. Mark for Review
(1) Points

True

False (*)

Incorrect. Refer to Section 14 Lesson 2.

Test: Using the PL/SQL Initialization Parameters: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. To set the PLSQL_CODE_TYPE to its fastest execution speed, which command do


you use? Mark for Review
(1) Points

ALTER SYSTEM SET PLSQL_CODE_TYPE=NATIVE;

ALTER SYSTEM SET PLSQL_CODE_TYPE=2;

ALTER SESSION SET PLSQL_CODE_TYPE = NATIVE; (*)

ALTER SESSION SET PLSQL_CODE_TYPE = INTERPRETED;

ALTER SESSION SET PLSQL_CODE_TYPE = 2;


Correct

2. PLSQL_CODE_TYPE determines the type of code for both PL/SQL code and for SQL
statements, which is what speeds up the execution speed. True or False? Mark for Review
(1) Points

True

False (*)

Correct

3. Which are NOT examples of benefits of using PLSQL_OPTIMIZE_LEVEL. (Choose


two) Mark for Review
(1) Points

(Choose all correct answers)

Control what PL/SQL does with useless code

Combining compiled code from one subprogram into another subprogram

Separating compiled code so that separate units may be repeated as needed


(*)
Backward compatible with previous versions of the Oracle database

Modify source code to optimize frequently-used elements at the top (*)

Correct

4. When setting PLSQL_OPTIMIZE_LEVEL = 2, the compiled code will remove code and
exceptions that can never be executed. True or False? Mark for Review
(1) Points

True (*)

False

Correct

5. Which data dictionary view allows you to see the setting for
PLSQL_OPTIMIZE_LEVEL? Mark for Review
(1) Points

USER_PLSQL_OBJECTS

USER_PLSQL_OPTIMIZE

USER_PLSQL_OBJECT_SETTINGS (*)

USER_OBJECT_SETTINGS

USER_PLSQL_CODE_TYPE

Correct

6. What are the valid values for PLSQL_OPTIMIZE_LEVEL in the data dictionary?
Mark for Review
(1) Points
0,1,2,3 (*)

0,1,2,3,4

1,2,3

1,2,3,4

Correct

Test: Displaying Compiler Warning Messages: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. An error in PL/SQL is when the compiler does not proceed successfully and an error
message is displayed. True or False? Mark for Review
(1) Points

True (*)

False

Correct

2. A warning in PL/SQL is the same as an error in PL/SQL, but can only be viewed
through the USER_ERRORS data dictionary view. True or False? Mark for Review
(1) Points

True

False (*)

Correct

3. Which PL/SQL warning message identifies code that can cause unexpected behavior
or wrong results when executed? Mark for Review
(1) Points

INFORMATIONAL

PERFORMANCE

ALL

SEVERE (*)

ERROR

Correct

4. The informational warning level for PL/SQL compiled code identifies the code that
may cause execution speed to be slow. True or False? Mark for Review
(1) Points
True

False (*)

Correct

5. The two statements below are equivalent. True or False?


DBMS_WARNING.ADD_WARNING_SETTING_CAT Mark for Review
('INFORMATIONAL','ENABLE','SESSION'); (1) Points

and

ALTER SESSION
SET PLSQL_WARNINGS = 'ENABLE:INFORMATIONAL';

True (*)

False

Correct

6. Which pair of DBMS_WARNING commands would allow you to obtain the current
settings and change and restore those settings in a PL/SQL subprogram? (Choose Mark for Review
two) (1) Points

(Choose all correct answers)

DBMS_WARNING.SET_WARNING_SETTING_STRING (*)

DBMS_WARNING.ADD_WARNING_SETTING_CAT

DBMS_WARNING.GET_WARNING_SETTING_STRING (*)

DBMS_WARNING.GET_WARNING_STRING

Correct

Test: Using Conditional Compilation: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. Conditional compilation allows you to include extra code to help with debugging,
which can be removed once errors are resolved. True or False? Mark for Review
(1) Points

True (*)

False

Correct
2. You can choose which code to include in a PL/SQL program based on conditional
compilation directives. True or False? Mark for Review
(1) Points

True (*)

False

Correct

3. Identify the selection directives used in conditional compilation.


Mark for Review
(1) Points

$IF
$THEN
$ELSE
$END
$CCFLAG
$$IF
$$THEN
$$ELSE
$$ELSIF
$$END
$IF
$THEN
$ELSE $ELSIF
$ENDIF
$IF
$THEN
$ELSE
$ELSIF
$END
(*)
$$IF
$$THEN
$$ELSE
$$END
$$DEBUG

Correct

4. Inquiry directives are used to selectively include or exclude PL/SQL code based on
values of pre-defined variables that are set using the PLSQL_CCFLAGS parameter. Mark for Review
True or False? (1) Points

True

False (*)

Correct

5. The value of DBMS_DB_VERSION.VER_LE_11 is TRUE when the version of the


Oracle database is version 11 or greater. True or False? Mark for Review
(1) Points

True

False (*)
Correct

6. If the version and release of the Oracle database in use is 10.2, what statement will
allow syntax available in version 10.2 or later? Mark for Review
(1) Points

$IF DBMS_DB_VERSION.VER_LE_10_2 $THEN


-- some messaage
$ELSE
-- some action
$END
$IF DBMS_DB_VERSION.VER_LE_10_2 $THEN
-- some messaage
$ELSE
-- some action
$END;
$IF DBMS_DB_VERSION.VER_LE_10_1 $THEN
-- some messaage
$ELSE
-- some action
$END
(*)
$IF DBMS_DB_VERSION.VER_LE_10_1 $THEN
-- some messaage
$ELSE
-- some action
$END;

Correct

Test: Hiding Your Source Code: Quiz

Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.

Section 1
(Answer all questions in this section)

1. One benefit of obfuscation is to protect intellectual property written in PL/SQL. True


or False? Mark for Review
(1) Points

True (*)

False

Correct

2. Obfuscation allows the owner to see the source code, but not the users to whom
EXECUTE privileges have been granted. True or False? Mark for Review
(1) Points

True

False (*)
Correct

3. When wrapping subprograms, the entire PL/SQL code must be included as an IN


argument with data type VARCHAR2 up to 32,767 characters. True or False? Mark for Review
(1) Points

True (*)

False

Correct

4. To obfuscate the procedure my_proc, what statement should be at Line A?


Mark for Review
BEGIN (1) Points
-- Line A
('CREATE OR REPLACE PROCEDURE mycleverproc
(p_param1 IN NUMBER, p_param2 OUT NUMBER)
IS BEGIN
... /* some clever but private code here */
END mycleverproc;');
END;

DBMS_DML.CREATE_WRAP

DBMS_DDL.CREATE_WRAP

DBMS_DDL.CREATE_WRAPPED (*)

DBMS_DDL.WRAPPED

DBMS_DDL.WRAP_CODE

Correct

5. To create obfuscated code using the wrapper utility, determine the order in which to
execute the following steps. Mark for Review
A Connect to the database and execute the wrapped text file as a script to compile (1) Points
the wrapped code into the Data Dictionary.
B Log into the database server computer.
C Create a text file containing your complete unwrapped source code.
D Execute WRAP to create a second text file containing the wrapped code.

A,B,C,D

B,C,D,A (*)

C,D,A,B

C,A,B,D

B,D,C,A

Correct

6. For PL/SQL code larger than 32,767 characters, you must use the wrap utility. True
or False? Mark for Review
(1) Points

True (*)
False

Correct

Potrebbero piacerti anche