Anda di halaman 1dari 88

6.01.

Handling Exceptions

1. Which of the following are NOT good practice guidelines for exception handling?
(Choose two.)

Test your code with different combinations of data to see what potential errors can happen.
Use an exception handler whenever there is any possibility of an error occurring.
Include a WHEN OTHERS handler as the first handler in the exception section. (*)
Allow exceptions to propagate back to the calling environment. (*)
Handle specific named exceptions where possible, instead of relying on WHEN OTHERS.

2. Which of these exceptions can be handled by an EXCEPTION section in a PL/SQL block?

An attempt is made to divide by zero


A SELECT statement returns no rows
Any other kind of exception that can occur within the block
All of the above (*)
None of the above

3. Which of the following best describes a PL/SQL exception?

A user enters an invalid password while trying to log on to the database.


An error occurs during the execution of the block, which disrupts the normal
operation of the program. (*)
A compile-time error occurs because the PL/SQL code references a non-existent table.
The programmer forgets to declare a cursor while writing the PL/SQL code.

4. The following EXCEPTION section is constructed correctly. True or False?

EXCEPTION
WHEN ZERO_DIVIDE OR TOO_MANY_ROWS OR NO_DATA_FOUND
THEN statement_1;
statement_2;
WHEN OTHERS
THEN statement_3;
END;
True (*)
False

5. Only one exception can be raised automatically during one execution of a PL/SQL block.
True or False?
True (*)
False

6. Which of the following EXCEPTION sections are constructed correctly? (Choose three.)

EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
END;

(*)

EXCEPTION
WHEN TOO_MANY_ROWS 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;

EXCEPTION
WHEN OTHERS THEN statement_1;
END;

(*)

EXCEPTION
WHEN OTHERS THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
END;

7. 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;
You should not use DBMS_OUTPUT.PUT_LINE in an exception handler.
department_id 75 does not exist in the departments table.
The exception handler should test for the named exception NO_DATA_FOUND. (*)
The exception handler should COMMIT the transaction.
The exception section should include a WHEN TOO_MANY_ROWS exception
handler. (*)

8. Which of the following is NOT an advantage of including an exception handler in a


PL/SQL block?
Prevents errors from occurring (*)
Code is more readable because error-handling routines can be written in the same block in
which the error occurred
Prevents errors from being propagated back to the calling environment
Avoids costly and time-consuming correction of mistakes

6.02. Trapping Oracle Server Exceptions

1. Which of the following is NOT a predefined Oracle Server error?


NO_DATA_FOUND
TOO_MANY_ROWS
e_sal_too_high EXCEPTION; (*)
ZERO_DIVIDE
DUP_VAL_ON_INDEX

2. Which type(s) of exception MUST be explicitly raised by the PL/SQL programmer?


User-defined exceptions. (*)
Predefined Oracle server errors such as TOO_MANY_ROWS.
Non-predefined Oracle server errors such as ORA-01203.
All of the above.

3. There are no employees whose salary is less than 2000. Which exception handlers would
successfully trap the exception which will be raised when the following code is executed?
(Choose two.)

DECLARE
v_mynum NUMBER := 10;
v_count NUMBER;
BEGIN
SELECT COUNT(*) INTO v_count FROM employees
WHERE salary < 2000;
v_mynum := v_mynum / v_count;
EXCEPTION
END;
NO_DATA_FOUND
ZERO_DIVIDE (*)
SQL%ROWCOUNT = 0
OTHERS (*)
OTHER
4. 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;

What will happen when this code is executed?

The code will execute and insert error number 02291 into error_log_table.
The code will fail because SQLCODE has not been declared.
The code will fail because we access error message numbers by using SQLERRNUM, not
SQLCODE.
The code will fail because we cannot use functions like SQLCODE directly in a SQL
statement. (*)

5. What is the correct syntax to associate an exception named EXCEPNAME with the non-
predefined Oracle Server error ORA-02292?

PRAGMA EXCEPTION_INIT (newname, -2292) (*)


RAISE_APPLICATION_ERROR (-2292, excepname);
SQLCODE (-2292, excepname);
WHEN (-2292, excepname) THEN ?

6. Which kind of error can NOT be handled by PL/SQL?

Syntax errors (*)


Predefined Oracle Server errors
Non-predefined Oracle Server errors
User-defined errors

7. Examine the following code. At Line A, you want to raise an exception if the employees
manager_id is null. What kind of exception is this?

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 predefined Oracle Server exception
A constraint violation
A non-predefined Oracle server exception
A user-defined exception (*)
A NO_DATA_FOUND exception

8. An ORA-1400 exception is raised if an attempt is made to insert a null value into a NOT
NULL column. DEPARTMENT_ID is the primary key of the DEPARTMENTS table. What
will happen when the following code is executed?

DECLARE
e_not_null EXCEPTION;
BEGIN
PRAGMA EXCEPTION_INIT(e_not_null, -1400);
INSERT INTO departments (department_id, department_name)
VALUES(null, Marketing);
EXCEPTION
WHEN e_not_null THEN
DBMS_OUTPUT.PUT_LINE(Cannot be null);
END;
The exception will be raised and Cannot be null will be displayed.
The code will not execute because the syntax of PRAGMA EXCEPTION_INIT is wrong.
The code will not execute because PRAGMA EXCEPTION_INIT must be coded in the
DECLARE section. (*)
The code will not execute because the syntax of the INSERT statement is wrong.

9. Which one of the following events would implicitly raise an exception?

The PL/SQL programmer mis-spells the word BEGIN as BEGAN.


A database constraint is violated. (*)
A SELECT statement returns exactly one row.
An UPDATE statement modifies no rows.

10. Which of the following best describes a predefined Oracle Server error?
Has a standard Oracle error number but must be declared and named by the PL/SQL
programmer
Has a standard Oracle error number and a standard name which can be referenced in
the EXCEPTION section (*)
Is associated with an Oracle error number using PRAGMA EXCEPTION_INIT
Is not raised automatically but must be declared and raised explicitly by the PL/SQL
programmer

11. How would you trap Oracle Server exception ORA-01403: no data found?
WHEN NO DATA FOUND THEN
WHEN ORA-01403 THEN
WHEN NO_DATA_FOUND THEN (*)
WHEN SQL%ROWCOUNT=0 THEN

12. A PL/SQL block executes and an Oracle Server exception is raised. Which of the
following contains the text message associated with the exception?

SQLCODE
SQLERRM (*)
SQL%MESSAGE
SQL_MESSAGE_TEXT

6.03. Trapping User-Defined Exceptions

1. What is a user-defined exception?

A predefined Oracle server exception such as NO_DATA_FOUND.


An exception which has a predefined Oracle error number but no predefined name.
An exception handler which the user (the programmer) includes in the EXCEPTION
section.
An exception which is not raised automatically by the Oracle server, but must be
declared and raised explicitly by the PL/SQL programmer. (*)

2. The following three steps must be performed to use a user-defined exception:


Raise the exception
Handle the exception
Declare the exception

In what sequence must these steps be performed?

Raise, Handle, Declare


Handle, Raise, Declare
Declare, Raise, Handle (*)
The steps can be performed in any order.

3. You want to display your own error message to the user. What is the correct syntax to do
this?

RAISE_APPLICATION_ERROR(20001, My own message);


RAISE_APPLICATION_ERROR(My own message, -20001);
RAISE application_error;
RAISE_APPLICATION_ERROR (-20001, My own message) (*)
4. How are user-defined exceptions raised ?

By PRAGMA EXCEPTION_INIT
By DECLARE e_my_excep EXCEPTION;
By RAISE exception_name; (*)
None of the above. They are raised automatically by the Oracle server.

5. What will be displayed when the following code is executed?

DECLARE
e_myexcep EXCEPTION;
BEGIN
DBMS_OUTPUT.PUT_LINE(Message 1);
RAISE e_myexcep;
DBMS_OUTPUT.PUT_LINE(Message 2);
EXCEPTION
WHEN e_myexcep THEN
DBMS_OUTPUT.PUT_LINE(Message 3);
RAISE e_myexcep;
DBMS_OUTPUT.PUT_LINE(Message 4);
END;
Message 1
Message 3
Message 1
Message 3
Message 4
Message 1
Message 2
Message 3
Message 4
The code will not execute because it contains at least one syntax error.
The code will execute but will return an unhandled exception to the calling
environment.(*)

6. What is wrong with the following code?


BEGIN
UPDATE employees SET salary = 20000
WHERE job_id = CLERK;
IF SQL%ROWCOUNT = 0 THEN
RAISE NO_DATA_FOUND; Line A
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE(No employee was updated);
END;
You cannot use SQL%ROWCOUNT in conditional control statements such as IF or CASE.
NO_DATA_FOUND has not been DECLAREd
Line A should be: HANDLE NO_DATA_FOUND
You cannot explicitly raise predefined Oracle Server errors such as NO_DATA_FOUND.
Nothing is wrong, the code will execute correctly. (*)

7. What is the datatype of a user-defined exception?


BOOLEAN
VARCHAR2
EXCEPTION (*)
NUMBER
None of the above

8. The following line of code is correct. True or False?


RAISE_APPLICATION_ERROR(-21001,My error message);

True
False (*)

6.04. Recognizing the Scope of Variables

1. What will be displayed when the following code is executed?


<<outer>>
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 25;
DECLARE
v_myvar NUMBER := 100;
BEGIN
outer.v_myvar := 30;
v_myvar := v_myvar / 0;
outer.v_myvar := 35;
END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END;
25
30 (*)
35
40
100
2. Three blocks (outer, middle and inner) are nested inside each other. A variable is declared
in the middle block. What is the scope of this variable?

Middle block only


Middle and inner blocks (*)
All three blocks
Middle and outer block only
None of the above

3. Why will the following code not execute correctly?

DECLARE
v_var1 NUMBER;
BEGIN
DECLARE
v_var2 NUMBER;
BEGIN
v_var1 := 20;
END;
v_var2 := 30;
END;
v_var1 cannot be referenced in the inner block.
v_var1 is a NUMBER variable and cannot be assigned a character string value.
v_var2 cannot be referenced in the outer block. (*)
The block labels are missing.
Nothing is wrong, the code will execute correctly

4. Examine the following code. What is the scope and visibility of the outer blocks
v_myvar?

DECLARE
v_myvar VARCHAR2(20);
BEGIN
DECLARE
v_myvar VARCHAR2(20);
BEGIN

END:

END;
It is in scope and visible in the outer block only.
It is in scope and visible in both blocks.
It is visible in both blocks but in scope only in the outer block.
It is in scope in both blocks but visible only in the outer block. (*)

5. Predefined Oracle Server exceptions such as NO_DATA_FOUND can be raised


automatically in inner blocks and handled in outer blocks. True or False?
True (*)
False

6. What will happen when the following code is executed?


DECLARE
e_outer_excep EXCEPTION;
BEGIN
DECLARE
e_inner_excep EXCEPTION;
BEGIN
RAISE e_outer_excep;
END;
EXCEPTION
WHEN e_outer_excep THEN
DBMS_OUTPUT.PUT_LINE(Outer raised);
WHEN e_inner_excep THEN
DBMS_OUTPUT.PUT_LINE(Inner raised);
END;
The code will execute successfully and Outer Raised will be displayed.
The code will propagate the e_outer_excep back to the calling environment (Application
Express).
The code will fail to compile because e_inner_excep cannot be referenced in the outer
block. (*)
The code will fail to compile because e_inner_excep was declared but never RAISEd.

7. In a pair of nested blocks, block labels such as <<label_name>> must be used for both
blocks or neither block. True or False?

True
False (*)

8. Which of the following will display the value Smith?

<<outer>>
DECLARE
v_name VARCHAR2(10) := Smith;
BEGIN
DECLARE
v_name VARCHAR2(10) := Jones;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_name);
END;
END;

<<outer>>
DECLARE
v_name VARCHAR2(10) := Smith;
BEGIN
DECLARE
v_name VARCHAR2(10) := Jones;
BEGIN
DBMS_OUTPUT.PUT_LINE(<<outer>>.v_name);
END;
END

<<outer>>
DECLARE
v_name VARCHAR2(10) := Smith;
BEGIN
DECLARE
v_name VARCHAR2(10) := Jones;
BEGIN
DBMS_OUTPUT.PUT_LINE(outer.v_name);
END;
END;(*)

<<outer>>
DECLARE
v_name VARCHAR2(10) := Smith;
BEGIN
<<inner>>
DECLARE
v_name VARCHAR2(10) := Jones;
BEGIN
DBMS_OUTPUT.PUT_LINE(v_name);
END;
END;

9. What will happen when the following code is executed?


DECLARE
e_excep1 EXCEPTION;
e_excep2 EXCEPTION;
BEGIN
RAISE e_excep1;
EXCEPTION
WHEN e_excep1 THEN BEGIN
RAISE e_excep2; END;
END;
It will fail to compile because you cannot have a subblock inside an exception section.
It will fail to compile because e_excep1 is out of scope in the subblock.
It will fail to compile because you cannot declare more than one exception in the same
block.
It will compile successfully and return an unhandled e_excep2 to the calling
environment. (*)
10. Explicit cursors are variables and follow the same scoping and visibility rules as other
types of variable. True or False?

True (*)
False

11. There are three employees in department 90. What will be displayed when this code is
executed?

DECLARE
v_last_name employees.last_name%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(Message 1);
BEGIN
SELECT last_name INTO v_last_name
FROM employees WHERE department_id = 90;
DBMS_OUTPUT.PUT_LINE(Message 2);
END;
DBMS_OUTPUT.PUT_LINE(Message 3);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(Message 4);
END;
Message 1
Message 3
Message 4
Message 1
Message 4(*)
Message 1
An unhandled exception will be propagated back to the calling environment.
None of the above

12. Non-predefined Oracle Server errors (associated with Oracle error numbers by
PRAGMA EXCEPTION_INIT) can be declared and raised in inner blocks and handled in
outer blocks. True or False?
True
False (*)

PLSQL Semester 1 Final Exam

Section 7

1. Exceptions declared in a block are considered local to that block, and global to all its
sub-blocks. True or False? (1) Points
True (*)
False

2. The following code does not violate any constraints and will not raise an ORA-02292
error. What will happen when the code is executed?
BEGIN
DECLARE
e_constraint_violation EXCEPTION;
PRAGMA EXCEPTION_INIT(e_constraint_violation, -2292);
BEGIN
DBMS_OUTPUT.PUT_LINE('Inner block message');
END;
EXCEPTION
WHEN e_constraint_violation THEN
DBMS_OUTPUT.PUT_LINE('Outer block message');
END;
(1) Points

'Inner block message' will be displayed.


The code will fail because the exception is declared in the inner block but is referenced in
the outer block. (*)

'Outer block message' will be displayed.


The code will fail because line 4 should read: PRAGMA EXCEPTION_INIT(-2292,
e_constraint_violation);

3. What will happen when the following code is executed?


DECLARE
e_excep1 EXCEPTION;
e_excep2 EXCEPTION;
BEGIN
RAISE e_excep1;
EXCEPTION
WHEN e_excep1 THEN BEGIN
RAISE e_excep2; END;
END;
(1) Points

It will fail to compile because you cannot have a subblock inside an exception section.
It will fail to compile because e_excep1 is out of scope in the subblock.
It will fail to compile because you cannot declare more than one exception in the same
block.
It will compile successfully and return an unhandled e_excep2 to the calling environment.
(*)

4. What will be displayed when the following code is executed?


<<outer>>
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 10;
DECLARE
v_myvar NUMBER := 200;
BEGIN
outer.v_myvar := 20;
v_myvar := v_myvar / 0; -- this raises a ZERO_DIVIDE error
outer.v_myvar := 30;
END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END;
(1) Points

10
20 (*)
30
40
200

5. While a PL/SQL block is executing, more than one exception can occur at the same time.
True or False? (1) Points

True
False (*)

6. Which of these exceptions can be handled by an EXCEPTION section in a PL/SQL


block? (1) Points

A SELECT statement returns no rows


A SELECT statement returns more than one row
Any other kind of exception that can occur within the block
All of the above (*)
None of the above

7. The following EXCEPTION section is constructed correctly. True or False?


EXCEPTION
WHEN NO_DATA_FOUND OR TOO_MANY_ROWS
THEN statement_1;
statement_2;
WHEN OTHERS
THEN statement_3;
END;
(1) Points

True (*)
False
8. Which of the following is NOT an advantage of including an exception handler in a
PL/SQL block? (1) Points

Protects the database from errors


Code is more readable because error-handling routines can be written in the same block in
which the error occurred

Prevents errors from occurring (*)


Avoids costly and time-consuming correction of mistakes

9. Examine the following code fragment. At Line A, you want to raise an exception if the
fetched salary value is greater than 30000. How can you do this?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 100;
IF v_salary > 30000 THEN
-- Line A
END IF;
...
(1) Points

Test for WHEN VALUE_TOO_HIGH in the exception section.


Use RAISE_APPLICATION_ERROR to raise an exception explicitly. (*)
Test for WHEN OTHERS in the exception section, because WHEN OTHERS traps all
exceptions.
Define an EXCEPTION variable and associate it with an Oracle Server error number using
PRAGMA EXCEPTION_INIT.

10. Which kinds of exceptions are raised implicitly (i.e., automatically)? (Choose two.) (1)
Points (Choose all correct answers)

Predefined Oracle Server errors such as NO_DATA_FOUND (*)


User-defined errors
All errors
Non-predefined Oracle Server errors such as ORA-01400 (*)

Section 7

11. Which of the following best describes a predefined Oracle Server error? (1) Points

Has a standard Oracle error number but must be named by the PL/SQL programmer
Is not raised automatically but must be declared and raised explicitly by the PL/SQL
programmer
Has a standard Oracle error number and a standard name which can be referenced in the
EXCEPTION section (*)
Is associated with an Oracle error number using PRAGMA EXCEPTION_INIT

12. The following exception handler will successfully insert the Oracle error number and
error message into a log table whenever an Oracle Server error occurs. True or False?
EXCEPTION
WHEN OTHERS THEN
INSERT INTO err_log_table (num_col, char_col)
VALUES (SQLCODE, SQLERRM);
END;
(Assume that err_log_table has been created with suitable columns and datatypes.)
(1) Points

True
False (*)

13. Examine the following code. What message or messages will be displayed when this
code is executed?
DECLARE
v_last_name employees.last_name%TYPE;
v_number NUMBER := 27;
BEGIN
v_number := v_number / 0;
SELECT last_name INTO v_last_name FROM employees
WHERE employee_id = 999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No rows were found');
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Attempt to divide by zero');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;
(1) Points

No rows were found


Attempt to divide by zero (*)
Attempt to divide by zero No rows were found
An error occurred
No message will be displayed

14. An attempt to update an employee's salary to a negative value will violate a check
constraint and raise an ORA-02290 exception. Which of the following is a correct definition
of a handler for this exception? (1) Points

DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);

DECLARE
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;

DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290); (*)

DECLARE
e_sal_excep EXCEPTION;
PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290);

DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);

15. A user-defined exception is raised by using: (1) Points

FLAG exception_name;
RAISE exception-name; (*)
PRAGMA EXCEPTION_INIT
RAISE(error_number, exception_name);

16. A user-defined exception must be declared as a variable of data type EXCEPTION. True
or False? (1) Points

True (*)
False

17. User-defined exceptions must be declared explicitly by the programmer, but then are
raised automatically by the Oracle Server. True or False? (1) Points

True
False (*)

18. Department-id 99 does not exist. What will be displayed when the following code is
executed?
DECLARE
v_deptname departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_deptname
FROM departments WHERE department_id = 99;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20201,'Department does not exist');
END;
(1) Points

ORA-01403: No Data Found ORA-20201: Department does not exist


ORA-01403: No Data Found
ORA-20201: Department does not exist (*)
None of the above

Section 8
19. You have created procedure MYPROC with a single parameter PARM1 NUMBER.
Now you want to add a second parameter to the procedure. Which of the following will
change the procedure successfully? (1) Points

ALTER PROCEDURE myproc ADD (parm2 NUMBER);


The procedure cannot be modified. Once a procedure has been created, the number of
parameters cannot be changed.
CREATE OR REPLACE PROCEDURE someproc (parm1 NUMBER, parm2 NUMBER);
(You do not need to repeat the detailed code of the procedure, only the header)
REPLACE PROCEDURE someproc (parm1 NUMBER, parm2 NUMBER) IS BEGIN ...
CREATE OR REPLACE PROCEDURE someproc (parm1 NUMBER, parm2 NUMBER)
IS BEGIN ... (*)

20. You have created the following procedure:


CREATE OR REPLACE PROCEDURE double_it
(p_param IN OUT NUMBER)
IS
BEGIN
p_param := p_param * 2;
END;
Which of the following anonymous blocks invokes this procedure successfully? (1) Points

BEGIN
EXECUTE double_it(20);
END;

BEGIN
SELECT double_it(20)
FROM DUAL;
END;

DECLARE
v_result NUMBER(6);
BEGIN
v_result := double_it(20);
END;

DECLARE
v_result NUMBER(6) := 20;
BEGIN
double_it(v_result);
END; (*)

BEGIN
double_it(20);
END;

21. Which of the following best describes how an IN parameter affects a procedure? (1)
Points
It describes the order in which the procedure's statements should be executed.
It describes which parts of the procedure's code are optional or conditional.
It makes the procedure execute faster.
It passes a value into the procedure when the procedure is invoked. (*)
It allows complex calculations to be executed inside the procedure.

22. You want to create a procedure named SOMEPROC which accepts a single parameter
named SOMEPARM. The parameter can be up to 100 characters long. Which of the
following is correct syntax to do this? (1) Points

CREATE PROCEDURE someproc


(someparm varchar2)
IS
BEGIN ...(*)

CREATE PROCEDURE someproc


(someparm varchar2(100) )
IS
BEGIN...

CREATE PROCEDURE someproc


IS
(someparm VARCHAR2;)
BEGIN...

CREATE PROCEDURE someproc


someparm varchar2(100);
IS
BEGIN...

CREATE PROCEDURE someproc


(someparm 100)
IS
BEGIN ...

23. You have created a procedure named MYPROC that accepts three IN parameters A, B,
and C (all numbers). Which of the following calls to MYPROC is NOT correct? (1) Points

myproc(5,10,20);
myproc(a=>5,b=>10,20) (*)
myproc(a=>5,b=>10,c=>20)
myproc(5,10,c=>20)

24. Which of the following are characteristics of PL/SQL subprograms but not of
anonymous PL/SQL blocks? (Choose three.) (1) Points (Choose all correct answers)

Can take parameters (*)


Are stored in the database (*)
Can begin with the keyword DECLARE
Are named (*)
Are compiled every time they are executed

25. A programmer creates a PL/SQL subprogram which is compiled and stored in the
database. Two separate users then execute an application which invokes this subprogram four
times. How many times must the subprogram be recompiled? (1) Points

Twice
Four times
None (*)
Eight times
Once

26. What is another name for a nested subprogram? (1) Points

Hosted subprogram
Local subprogram (*)
Limited subprogram

27. A stored PL/SQL procedure can be invoked from which of the following?

A PL/SQL anonymous block


Another PL/SQL procedure
A calling application (1) Points

A only
A and B
A and C
A, B and C (*)
B and C

28. View and reload your code later by clicking on the History button in the SQL
Commands window. True or False? (1) Points

True
False (*)

29. A programmer wants to create a PL/SQL procedure named EMP_PROC. What will
happen when the following code is executed?
CREATE OR REPLACE PROCEDURE emp_proc IS
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 999;
DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary);
END;
(1) Points

The statement will raise a NO_DATA_FOUND exception because employee_id 999 does not
exist.
The statement will fail because the last line of code should be END emp_proc;
The statement will fail because you cannot declare variables such as v_salary inside a
procedure.
The procedure will be created successfully. (*)
The statement will fail because the procedure does not have any parameters.

30. The following procedure has been created:


CREATE OR REPLACE PROCEDURE defproc
(A IN NUMBER := 50,
B IN NUMBER,
C IN NUMBER DEFAULT 40)
IS .....
Which one of the following will invoke the procedure correctly?
(1) Points

defproc(30 => A);


defproc(30, 60 => C);
defproc(40, 70); (*)
defproc(10 => A, 25 => C);
defproc;

31. What are the type of parameter modes? (1) Points

CHARACTER, NUMBER, DATE, BOOLEAN


CONSTANT, VARIABLE, DEFAULT
LOCAL, GLOBAL, BOTH
IN, OUT, IN OUT (*)

32. Procedure SOMEPROC has five parameters named A, B, C, D, E in that order. The
procedure was called as follows:
SOMEPROC(10,20,D=>50);
How was parameter B referenced?
(1) Points

Positional (*)
Named
A combination of positionally and named
A combination of named and defaulted
Defaulted

33. Procedure SOMEPROC has five parameters named A, B, C, D, E in that order. The
procedure was called as follows:
SOMEPROC(10,20,D=>50);

How was parameter D referenced?


(1) Points

Positionally
Named (*)
A combination of positionally and named
A combination of named and defaulted
Defaulted

Section 9

34. When creating a user-defined function, the size of the returned values may be up to the
size of any PL/SQL data type. True or False? (1) Points

True
False (*)

35. Which of the following is a legal location for a function call in a SQL statement?
(Choose 3) (1) Points
(Choose all correct answers)

CREATE TABLE statement


WHERE clause in a DELETE statement (*)
The ORDER BY and GROUP BY clauses of a query (*)
VALUES clause of an INSERT statement (*)

36. A benefit of user-defined functions is that the function can accept any SQL or PL/SQL
data type. True or False? (1) Points

True
False (*)

37. Examine the following code (the code of CHILD2 is not shown):
CREATE PROCEDURE child1
IS v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 9999;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END child1;

CREATE PROCEDURE parent


IS BEGIN
child1;
child2;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END parent;

Employee_id 9999 does not exist. What happens when PARENT is executed?
(1) Points

CHILD1 handles the exception successfully and ends. PARENT continues to execute and
invokes CHILD2. (*)

CHILD1 ends abruptly, PARENT handles the exception successfully and ends. CHILD2
does not execute.

CHILD1 ends abruptly, then PARENT also ends abruptly with an unhandled exception.

PARENT handles the exception, then CHILD1 resumes execution.

PARENT fails to compile because you cannot have the same exception handler in two
separate subprograms.

38. The following code shows the dependencies between three procedures:
CREATE PROCEDURE parent
IS BEGIN
child1;
child2;
END parent;
You now try to execute:

DROP PROCEDURE child2;


What happens?
(1) Points

You cannot drop CHILD2 because PARENT is dependent on it.


CHILD2 is dropped successfully. PARENT and CHILD1 are both marked INVALID.
The database automatically drops PARENT as well.
CHILD2 is dropped successfully. PARENT is marked INVALID. CHILD1 is still valid. (*)
The database automatically drops CHILD1 as well.

39. You want to see the names, modes and data types of the formal parameters of function
MY_FUNC in your schema. How can you do this? (Choose two) (1) Points (Choose all
correct answers)

Query USER_PARAMETERS
Query USER_SOURCE (*)
Query USER_FUNCTIONS
SHOW PARAMETER my_func;
DESCRIBE my_func; (*)

40. Examine the following code:


CREATE OR REPLACE FUNCTION add_func
(p_param1 NUMBER, p_param2 NUMBER)
RETURN NUMBER
IS
BEGIN
RETURN (p_param1 + p_param2);
END;
What will be displayed when the following SQL statement is executed?
SELECT add_func(6, add_func(3,8)) FROM dual;
(1) Points

23
11
66
17 (*)
An error message will be displayed because you cannot nest user-defined functions.

Section 9

41. Why will this function not compile correctly?


CREATE FUNCTION bad_one
IS BEGIN
RETURN NULL;
END bad_one;
(1) Points

You cannot RETURN a NULL.


You must declare the type of the RETURN before the IS. (*)
You must have at least one IN parameter.
You must code CREATE OR REPLACE, not CREATE.
The body of the function must contain at least one executable statement (as well as
RETURN).

42. Which of the following is a difference between a procedure and a function? (1) Points

Functions cannot be nested; procedures can be nested to at least 8 levels.


A procedure can have default values for parameters, while a function cannot.
An explicit cursor can be declared in a procedure, but not in a function.
A function cannot be used within a SQL statement; a procedure can be used within SQL.
A function must return a value, a procedure may or may not. (*)

43. You have created a function named NEWFUNC. You now change some of the function
code, and try to recreate the function by executing:
CREATE OR REPLACE FUNCTION newfunc .... ;
What happens?
(1) Points

The command fails because the function already exists.


The function is automatically dropped and then recreated. (*)
The command fails because you should execute: CREATE AND REPLACE ....;
A second function named NEWFUNC_2 is created.
The function is dropped but not recreated.

44. Consider the following function:


CREATE FUNCTION ADD_EM
(a NUMBER := 1,
b NUMBER := 2 )
RETURN NUMBER
IS BEGIN
RETURN (a+b);
END ADD_EM;
Which one of the following blocks will NOT work correctly?
(1) Points

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;

DECLARE
x NUMBER;
BEGIN
x:= add_em;
END;

None of them will work.

45. What is wrong with the following code?


CREATE FUNCTION badfunc
(p_param NUMBER(4))
RETURN BOOLEAN
IS BEGIN
RETURN (p_param > 10);
END badfunc;
(1) Points

P_PARAM must be declared AFTER the RETURN clause.


P_PARAM must have a default value.
The datatype of the IN parameter cannot have a precision or scale. It must be NUMBER,
not NUMBER(4). (*)
RETURN (p_param > 10); is wrong because you cannot return an expression.
The NUMBER datatype must have a scale as well as a precision.

46. How do you specify that you want a procedure MYPROCA to use "Definer's Rights"?
(1) Points

CREATE OR REPLACE PROCEDURE myproca


AUTHID CURRENT_USER IS...
CREATE OR REPLACE PROCEDURE myproca
AUTHID OWNER IS...

GRANT DEFINER TO myprocA;

ALTER PROCEDURE myproca TO DEFINER;

Definer's Rights are the default, therefore no extra code or commands are needed. (*)

47. When must AUTHID CURRENT_USER be included in an autonomous transaction


subprogram? (1) Points

When declaring Definer's rights


When declaring Invoker's rights (*)
When using COMMIT or ROLLBACK
When using GRANT on the subprogram

48. What will happen when the following procedure is executed?


PROCEDURE log_usage (p_card_id NUMBER, p_loc NUMBER)
IS
PRAGMA AUTONOMOUS_TRANSACTION
BEGIN
INSERT INTO log_table (card_id, location, tran_date)
VALUES (p_card_id, p_loc, SYSDATE);
COMMIT;
END log_usage;
(1) Points

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.
The compilation will fail because a semicolon after AUTONOMOUS_TRANSACTION is
required. (*)
The program will compile successfully.

Section 6

49. Examine the following code. To create a row trigger, what code should be included at
Line A?
CREATE TRIGGER dept_trigg
AFTER UPDATE OR DELETE ON departments
-- Line A
BEGIN ...
(1) Points

AFTER EACH ROW


FOR EVERY ROW
FOR EACH ROW (*)
ON EACH ROW
ON EVERY ROW
50. Examine this code:
CREATE TRIGGER de_trigg
-- Line A
BEGIN ...

Which of the following are NOT valid at Line A ? (Choose two.) (1) Points (Choose all
correct answers)

AFTER LOGOFF ON SCHEMA (*)


AFTER LOGON ON SCHEMA
BEFORE LOGOFF ON SCHEMA
BEFORE DISCONNECT ON SCHEMA (*)
AFTER SERVERERROR ON SCHEMA

Section 6

1. A user-defined exception is raised by using: (1) Points


FLAG exception_name;
RAISE exception-name; (*)
PRAGMA EXCEPTION_INIT
RAISE(error_number, exception_name);

2. A user-defined exception can be raised: (1) Points


A. In the declaration section
B. In the executable section
C. In the exception section
B
C
A and B
B and C (*)
A and C

3. Which of the following will successfully return a user - defined error message?
(1) Points
RAISE_APPLICATION_ERROR('Error Raised',22001);
RAISE_APPLICATION_ERROR(-20257,'Error raised'); (*)
RAISE_APPLICATION_ERROR(-22001,'Error Raised');
RAISE_APPLICATION_ERROR('Error Raised',20257);

4. Department-id 99 does not exist. What will be displayed when the following
code is executed?
DECLARE
v_deptname departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_deptname
FROM departments WHERE department_id = 99;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20201,'Department
does not exist');
END;

ORA-01403: No Data Found ORA-20201: Department does not exist


ORA-01403: No Data Found
ORA-20201: Department does not exist (*)
None of the above

5. Which of the following EXCEPTION sections are constructed correctly? (Choose


two.) (Choose all correct answers)
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 NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;

EXCEPTION
WHEN OTHERS THEN statement_1;
END; (*)

6. Examine the following code. Why does the 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;

You should not use DBMS_OUTPUT.PUT_LINE in an exception handler.


employee_id 999 does not exist in the employees table.
The exception handler should test for the named exception NO_DATA_FOUND. (*)
The exception handler should COMMIT the transaction.

7. The following EXCEPTION section is constructed correctly. True or False?


EXCEPTION
WHEN NO_DATA_FOUND OR TOO_MANY_ROWS
THEN statement_1;
statement_2;
WHEN OTHERS
THEN statement_3;
END;

True (*)
False

8. Which of the following are good practice guidelines for exception handling?
(Choose three.) (Choose all correct answers)
Test your code with different combinations of data to see what potential errors
can happen. (*)
Use an exception handler whenever there is any possibility of an error occurring.
(*)
Include a WHEN OTHERS handler as the first handler in the exception section.
Allow exceptions to propagate back to the calling environment.
Handle specific named exceptions where possible, instead of relying on WHEN
OTHERS. (*)

9. What will happen when the following code is executed?


BEGIN --outer block
DECLARE --inner block
CURSOR emp_curs IS SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE;
BEGIN
OPEN emp_curs;
LOOP
FETCH emp_curs INTO v_emp_rec;
DBMS_OUTPUT.PUT_LINE(v_emp_rec.salary);
END LOOP;
END;
CLOSE emp_curs;
END;

The code will fail because you cannot declare a cursor in an inner block.
The code will fail because the cursor is declared in the inner block but is
referenced in the outer block. (*)
The code will execute successfully and display all the employees' salaries.
The code will execute forever because there is no statement to EXIT from the
loop.

10.What will be displayed when the following code is executed? What will be
displayed when the following code is executed?
<<outer>>
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 10;
DECLARE
v_myvar NUMBER := 200;
BEGIN
outer.v_myvar := 20;
v_myvar := v_myvar / 0; --this raises a ZERO_DIVIDE error
outer.v_myvar := 30;
END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END;

10
20 (*)
30
40
200

11. Using two nested blocks, a TOO_MANY_ROWS exception is raised within the
inner block. Which of the following exception handlers will successfully handle
the exception?

WHEN TOO_MANY_ROWS in the inner block


WHEN TOO_MANY_ROWS in either block
WHEN OTHERS in either block
WHEN OTHERS in the inner block
All of the above (*)

12. The following code will execute correctly. True or False?


DECLARE
v_myvar1 NUMBER;
BEGIN
DECLARE
v_myvar2 NUMBER;
BEGIN
v_myvar1 := 100;
END;
v_myvar2 := 100; v END;

True
False (*)

13. Examine the following code. What is the scope and visibility of the outer
block's v_last_name?
DECLARE
v_last_name VARCHAR2(20);
BEGIN
DECLARE
v_last_name VARCHAR2(20);
BEGIN
...
END:
...

END;

It is in scope and visible in both blocks.


It is in scope and visible in the outer block only.
It is in scope in both blocks, but visible only in the outer block. (*)
It is visible in both blocks, but in scope only in the outer block.

14. The following code does not violate any constraints and will not raise an ORA-
02292 error. What will happen when the code is executed?
BEGIN
DECLARE
e_constraint_violation EXCEPTION;
PRAGMA EXCEPTION_INIT(e_constraint_violation, -2292);
BEGIN
DBMS_OUTPUT.PUT_LINE('Inner block message');
END;
EXCEPTION
WHEN e_constraint_violation THEN
DBMS_OUTPUT.PUT_LINE('Outer block message');
END;

Inner block message' will be displayed.


The code will fail because the exception is declared in the inner block but is
referenced in the outer block.(*)
Outer block message' will be displayed.
The code will fail because line 4 should read: PRAGMA EXCEPTION_INIT(-2292,
e_constraint_violation);

15. 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;
OPEN emp_curs;
CLOSE emp_curs;
EXCEPTION ...
END;
(1) Points (Choose all correct answers)

WHEN CURSOR_NOT_OPEN
WHEN INVALID_CURSOR (*)
WHEN OTHERS (*)
WHEN NO_DATA_FOUND
WHEN INVALID_FETCH

16. Which of the following best describes a predefined Oracle Server error? (1)
Points

Has a standard Oracle error number but must be named by the PL/SQL
programmer
Is not raised automatically but must be declared and raised explicitly by the
PL/SQL programmer
Has a standard Oracle error number and a standard name which can be
referenced in the EXCEPTION section (*)
Is associated with an Oracle error number using PRAGMA EXCEPTION_INIT

17. Examine the following code. What message or messages will be displayed
when this code is executed?
DECLARE
v_last_name employees.last_name%TYPE;
v_number NUMBER := 27;
BEGIN
v_number := v_number / 0;
SELECT last_name INTO v_last_name FROM employees
WHERE employee_id = 999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No rows were found');
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Attempt to divide by zero');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;

No rows were found


Attempt to divide by zero (*)
Attempt to divide by zero No rows were found
An error occurred
No message will be displayed

18. Which kinds of exceptions are raised implicitly (i.e., automatically)? (Choose
two.) (1) Points
(Choose all correct answers)
Predefined Oracle Server errors such as NO_DATA_FOUND (*)
User-defined errors
All errors
Non-predefined Oracle Server errors such as ORA-01400 (*)

19. Examine the following code fragment. At Line A, you want to raise an
exception if the fetched salary value is greater than 30000. How can you do this?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 100;
IF v_salary > 30000 THEN
--Line A
END IF;
...

Test for WHEN VALUE_TOO_HIGH in the exception section.

Use RAISE_APPLICATION_ERROR to raise an exception explicitly. (*)


Test for WHEN OTHERS in the exception section, because WHEN OTHERS traps all
exceptions.
Define an EXCEPTION variable and associate it with an Oracle Server error
number using PRAGMA EXCEPTION_INIT.

20. An attempt to update an employee's salary to a negative value will violate a


check constraint and raise an ORA-02290 exception. Which of the following is a
correct definition of a handler for this exception?

DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);

DECLARE
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290); (*)

DECLARE
e_sal_excep EXCEPTION;
PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290);

DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);

21. You have created a procedure named MYPROC that accepts three
IN parameters A, B, and C (all numbers). Which of the following calls to MYPROC
is NOT correct?

myproc(5,10,20);
myproc(a=>5,b=>10,20) (*)
myproc(a=>5,b=>10,c=>20)
myproc(5,10,c=>20)

22. You have created procedure MYPROC with a single parameter PARM1
NUMBER. Now you want to add a second parameter to the procedure. Which of
the following will change the procedure successfully?

ALTER PROCEDURE myproc ADD (parm2 NUMBER);


The procedure cannot be modified. Once a procedure has been created, the
number of
parameters cannot be changed.

CREATE OR REPLACE PROCEDURE someproc


(parm1 NUMBER, parm2 NUMBER);
(You do not need to repeat the detailed code of the procedure, only the header)

REPLACE PROCEDURE someproc


(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ...

CREATE OR REPLACE PROCEDURE MYPROC


(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ... (*)

23. Which of the following best describes how an IN parameter affects a


procedure?
It describes the order in which the procedure's statements should be executed.
It describes which parts of the procedure's code are optional or conditional.
It makes the procedure execute faster.
It passes a value into the procedure when the procedure is invoked. (*)
It allows complex calculations to be executed inside the procedure.

24. Which of the following is NOT correct coding for a procedure parameter?

(p_param IN VARCHAR2)
(p_param VARCHAR2)
(p_param VARCHAR2(50)) (*)
(p_param employees.last_name%TYPE)
(p_param IN OUT VARCHAR2)

25. Which of the following statements about actual parameters is NOT true?

An actual parameter is declared in the calling environment, not in the called


procedure
An actual parameter must be the name of a variable (*)
An actual parameter can have a Boolean datatype
The datatypes of an actual parameter and its formal parameter must be
compatible
An actual parameter can have a TIMESTAMP datatype

26. Examine the following procedure:


CREATE OR REPLACE PROCEDURE smallproc
(p_param IN NUMBER)
IS
BEGIN ....
The procedure is invoked by:
DECLARE
v_param NUMBER := 20;
BEGIN
smallproc(v_param);
END;
Which of the following statements is true?

p_param is a parameter and v_param is an argument


p_param is a formal parameter and 20 is an actual parameter
p_param is a formal parameter and v_param is an actual parameter (*)
p_param and v_param are both formal parameters, while 20 is an actual
parameter
p_param is an actual parameter and v_param is a formal parameter

27. Which of the following are characteristics of PL/SQL subprograms but not
of anonymous PL/SQL blocks? (Choose three.) (Choose all correct answers)

Can take parameters (*)


Are stored in the database (*)
Can begin with the keyword DECLARE
Are named (*)
Are compiled every time they are executed

28. One PL./SQL subprogram can be invoked from within many applications. True
or False?

True (*)
False

29. A programmer wants to create a PL/SQL procedure named EMP_PROC.


What will happen when the following code is executed?
CREATE OR REPLACE PROCEDURE emp_proc IS
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employees
WHERE employee_id = 999;
DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary);
END; END;

The statement will raise a NO_DATA_FOUND exception because employee_id 999


does not exist.
The statement will fail because the last line of code should be END emp_proc;
The statement will fail because you cannot declare variables such as v_salary
inside a procedure.
The procedure will be created successfully. (*)
The statement will fail because the procedure does not have any parameters.

30. A programmer creates a PL/SQL subprogram which is compiled and stored in


the database. Two separate users then execute an application which invokes this
subprogram four times. How many times must the subprogram be recompiled?

Twice
Four times
None (*)
Eight times
Once

31. A PL/SQL stored procedure can accept one or more input parameters and can
return one or more output values to the calling environment. True or False?

True (*)
False
32. 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.) (Choose
all correct answers)

DECLARE
v_var1 NUMBER := 20;
BEGIN
my_proc1(v_var1);
END;

EXECUTE my_proc1;
BEGIN
my_proc1;
END; (*)

CREATE OR REPLACE PROCEDURE my_proc2 IS


BEGIN
my_proc1;
END my_proc2; (*)

SELECT my_proc1 FROM DUAL;

33. Which parameter mode is the default?

IN (*)
OUT
NUMBER
VARIABLE
CONSTANT

34. The following procedure has been created:

CREATE OR REPLACE PROCEDURE defproc


(A IN NUMBER := 50,
B IN NUMBER,
C IN NUMBER DEFAULT 40)
IS .....
Which one of the following will invoke the procedure correctly?

defproc(30 => A);


defproc(30, 60 => C);
defproc(40, 70); (*)
defproc(10 => A, 25 => C);
defproc;
35. Procedure SOMEPROC has five parameters named A, B, C, D, E in that order.
The procedure was called as follows:
SOMEPROC(10,20,D=>50);
How was parameter D referenced?

Positionally
Named (*)
A combination of positionally and named
A combination of named and defaulted
Defaulted

36. The following procedure has been created:

CREATE OR REPLACE PROCEDURE myproc


(A IN NUMBER := 20,
B IN NUMBER,
C IN NUMBER DEFAULT 30)
IS .....
Which of the following will invoke the procedure correctly?

myproc(40);
myproc(10, B => 30, 50);
myproc(C => 25);
All of the above
None of the above (*)

37. Examine the following code: CREATE


PROCEDURE parent
IS BEGIN
child1;
child2;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END parent;

Neither CHILD1 nor CHILD2 has an exception handler.


When PARENT is invoked, CHILD1 raises a NO_DATA_FOUND exception. What
happens next?

PARENT handles the exception, then CHILD1 continues to execute.


CHILD1 ends abruptly. PARENT handles the exception and then ends. CHILD2
does not execute. (*)

CHILD1 ends abruptly, PARENT handles the exception, then CHILD2 executes.

CHILD1 ends abruptly, PARENT also ends abruptly and returns an unhandled
exception. xception.
PARENT does not compile because you cannot use NULL; in an exception handler.

38. You want to see the names, modes and data types of the formal parameters
of function MY_FUNC in your schema. How can you do this? (Choose two)
(Choose all correct answers)

Query USER_PARAMETERS
Query USER_SOURCE (*)
Query USER_FUNCTIONS
SHOW PARAMETER my_funct;
DESCRIBE my_funct; (*)

39. You want to remove the procedure NO_NEED from your schema. You execute:
DROP PROCEDURE no_need;
Which Data Dictionary views are updated automatically?

USER_PROCEDURES
USER_OBJECTS
USER_SOURCE
All of the above. (*)
None of the above.

40. A function named MYFUNC has been created. This function accepts one IN
parameter of datatype VARCHAR2 and returns a NUMBER.
You want to invoke the function within the following anonymous block:

DECLARE
v_var1 NUMBER(6,2);
BEGIN
--Line A
END;
What could be coded at Liine A?

myfunc('Crocodile') := v_var1;
myfunc(v_var1) := 'Crocodile';
myfunc(v_var1, 'Crocodile');
v_var1 := myfunc('Crocodile'); (*)
myfunc('Crocodile', v_var1);

41. Examine the following code:


CREATE OR REPLACE FUNCTION add_func
(p_param1 NUMBER, p_param2 NUMBER)
RETURN NUMBER
IS
BEGIN
RETURN (p_param1 + p_param2);
END;
What will be displayed when the following SQL statement is executed?
SELECT add_func(6, add_func(3,8)) FROM dual;

23
11
66
17 (*)

42. You have created a function named NEWFUNC. You now change some of the
function code, and try to recreate the function by executing:
CREATE OR REPLACE FUNCTION newfunc .... ;
What happens?

The command fails because the function already exists.


The function is automatically dropped and then recreated. (*)
The command fails because you should execute: CREATE AND REPLACE ....;
A second function named NEWFUNC_2 is created.
The function is dropped but not recreated.

43. Which of the following is a difference between a procedure and a function?

A procedure can include DML statements, but a function cannot.


A function must have at least one IN parameter, while parameters are optional
for a procedure.
A procedure can return a BOOLEAN datatype, while a function cannot.
A function can be used inside a SQL statement, while a procedure cannot. (*)
A procedure can include an EXCEPTION section, while a function cannot.

44. You try to create a function named MYFUNC. The function does not compile
correctly because there are errors in your code. Which Dictionary view can you
query to see the errors?

USER_SOURCE

USER_ERRORS (*)
USER_OBJECTS
USER_DEPENDENCIES
USER_COMPILES
USER_OBJECTS
USER_DEPENDENCIES
USER_COMPILES

45. Consider the following function:


CREATE FUNCTION ADD_EM (a NUMBER := 1, b NUMBER := 2 )
RETURN NUMBER
IS BEGIN
RETURN (a+b);
END ADD_EM;
Which one of the following blocks will NOT work correctly?

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;

DECLARE
x NUMBER;
BEGIN
x:= add_em;
END;

None of them will work.

46. In which DML statements can user-defined functions be used?

INSERT and UPDATE, but not DELETE.


INSERT only.
All DML statements. (*)
UPDATE only
DELETE only

47. What is one of the advantages of using user-defined functions in a SQL


statement?

They automate repetitive formulas which otherwise you would have to type in
full
every time you used them. (*)
They execute faster than system-defined functions such as UPPER and LOWER.
They allow you to execute DML from inside a SELECT statement.
They allow you to use functions which return a BOOLEAN.
They are stored on your local PC, not in the database.

48. Where can a function be used in a query?

Nowhere in a query.

Anywhere in a query. (*)


Only in the SELECT clause
Only in the WHERE clause
In the SELECT or WHERE clauses, but not in the ORDER BY clause.

49. How do you specify that you want a procedure MYPROCA to use Invoker's
Rights?

CREATE OR REPLACE PROCEDURE myproca


AUTHID CURRENT_USER IS... (*)
Invoker's Rights are the default, therefore no extra code is needed.
GRANT INVOKER TO myprocA;
ALTER PROCEDURE myproca TO INVOKER;
CREATE OR REPLACE PROCEDURE myproca
AUTHID OWNER IS...

50. How do you specify that you want a procedure MYPROCA to use "Definer's
Rights"?

CREATE OR REPLACE PROCEDURE myproca


AUTHID CURRENT_USER IS...
CREATE OR REPLACE PROCEDURE myproca
AUTHID OWNER IS...
GRANT DEFINER TO myprocA;
ALTER PROCEDURE myproca TO DEFINER;
Definer's Rights are the default, therefore no extra code or commands are
needed. (*)

TEST 1...............................................

1. You can store a whole record in a single variable using %ROWTYPE or by


creating yoru own record structure as a type and then declaring a variable of th
at type. Mark for Review (1) Points

True (*)

False
Correct

2. An INDEX BY TABLE type can only have one data field. Mark for Review (1)
Points

True (*)

False

Correct

Section 9 (Answer all questions in this section)

3. The function avg_ann_sal returns the average annual sal ary for a particular
department. The example below is a valid use of of this fun ction. True or False?
SELECT first_name, last_name FROM employees WHERE avg_ann_sal(20) >
15000; Mark for Review (1) Points

True (*)

False

Correct

4. Which of the following is a legal location for a functi on call in a SQL


statement? (Choose 3) Mark for Review (1) Points

(Choose all correct answers)

CREATE TABLE statement

WHERE clause in a DELETE statement (*)

The ORDER BY and GROUP BY clauses of a q

uery (*)

VALUES clause of an INSERT statement (*)

Correct

5. Why will the following statement fail? SELECT employee_id, tax(p_value =>
salary) FROM employees; Mark for Review (1) Points

User-defined functions are not allowed i

n the SELECT clause

Name notation is not allowed (*)

The data type for the tax variable does

not match the data type for salary

The statement will execute and not fail


Correct

6. In a SELECT statement, where can a function NOT be used ? Mark for Review
(1) Points

In a GROUP BY or HAVING clause.

A function can be used anywhere in a SEL

ECT statement. (*)

In a WHERE clause.

In the column list (SELECT) clause.

In an ORDER BY clause.

Incorrect. Refer to Sec

tion 9 Lesson 1.

7. Which of the following best describes a stored function ? Mark for Review (1)
Points

A subprogram that must return exactly on

e value. (*)

A subprogram that must have at least one

IN parameter.

A subprogram that has no OUT or IN OUT p

arameters.

A subprogram that executes automatically when a DML statement is executed on


a table.

A subprogram which invokes another subpr

ogram.

Correct

8. Why will this function not compile correctly? CREATE FUNCTION bad_one IS
BEGIN RETURN NULL; END bad_one; Mark for Review (1) Points

You cannot RETURN a NULL.

You must declare the type of the RETURN

before the IS. (*)

You must have at least one IN parameter.


You must code CREATE OR REPLACE, not CRE

ATE.

The body of the function must contain at least one executable statement (as well
as RETURN).

Incorrect. Refer to Sec

tion 9 Lesson 1.

9. A function must have at least one IN parameter, and mus t return exactly one
value. Mark for Review (1) Points

True

False (*)

Correct

10. What is wrong with the following code? CREATE FUNCTION badfunc
(p_param NUMBER(4)) RETURN BOOLEAN IS BEGIN RETURN (p_param >
10); END badfunc; Mark for Review (1) Points

P_PARAM must be declared AFTER the RETUR

N clause.

P_PARAM must have a default value.

The datatype of the IN parameter cannot have a precision or scale. It must be


NUMBER, not NUMBER(4). (*)

RETURN (p_param > 10); is wrong because

you cannot return an expression.

The NUMBER datatype must have a scale as

well as a precision.

11. You try to create a function named MYFUNC. The function does not compil e
correctly because there are errors in your code. Which Dictionary view can you
query to see the errors? Mark for Review (1) Points

USER_SOURCE

USER_ERRORS (*)

USER_OBJECTS

USER_DEPENDENCIES

USER_COMPILES
Correct

12. You want to see the names, modes and data types of the formal parameters
of function MY_FUNC in your schema. How can you do this? (Choo se two) Mark
for Review (1) Points

(Choose all correct answers)

Query USER_PARAMETERS

Query USER_SOURCE (*)

Query USER_FUNCTIONS

SHOW PARAMETER my_func;

DESCRIBE my_func; (*)

Correct

13. You want to remove the procedure NO_NEED from your sche ma. You
execute: DROP PROCEDURE no_need; Which Data Dictionary views are updated
automatically? Mark for Review

(1) Points

USER_PROCEDURES

USER_OBJECTS

USER_SOURCE

All of the above. (*)

None of the above.

Correct

14. The following code shows the dependencies between three

procedures: CREATE PROCEDURE parent IS BEGIN child1; child2; END


parent; You now try to execute:

DROP PROCEDURE child2; What happens? Mark for Review (1) Points

You cannot drop CHILD2 because PARENT is

dependent on it.

CHILD2 is dropped successfully. PARENT a

nd CHILD1 are both marked INVALID.

The database automatically drops PARENT


as well.

CHILD2 is dropped successfully. PARENT i s marked INVALID. CHILD1 is still valid.


(*)

The database automatically drops CHILD1

as well.

Correct

15. User REYHAN creates the following procedure: CREATE PROCEDURE proc1
AUTHID CURRENT_USER IS v_count NUMBER; BEGIN SELECT COUNT(*)
INTO v_count FROM tom.employees; END;

User BILL wants to execute this procedure. What privileges will BILL need? Mark
for Review (1) Points

EXECUTE on REYHAN.PROC1 and SELECT on TO

M.EMPLOYEES (*)

EXECUTE on REYHAN.PROC1

SELECT on TOM.EMPLOYEES

BILL needs no privileges

None of the above. The procedure will fa il to compile because REYHAN does not
have SELECT privilege on TOM.EMPLOYEES.

Correct

16. How do you specify that you want a procedure MYPROCA to use "Definer's
Rights"? Mark for Review (1) Points

CREATE OR REPLACE PROCEDURE myproca

AUTHID CURRENT_USER IS...

CREATE OR REPLACE PROCEDURE myproca

AUTHID OWNER IS...

GRANT DEFINER TO myprocA;

ALTER PROCEDURE myproca TO DEFINER;

Definer's Rights are the default, theref ore no extra code or commands are
needed. (*)

Correct
17. When must AUTHID CURRENT_USER be included in an autonom ous
transaction subprogram? Mark for Review (1) Points

When declaring Definer's rights

When declaring Invoker's rights (*)

When using COMMIT or ROLLBACK

When using GRANT on the subprogram

Correct

Section 7 (Answer all questions in this section)

18. There are no employees in department 99. What message o r messages will
be displayed when the following code is executed? DECLARE e_my_excep
EXCEPTION; BEGIN BEGIN UPDATE employees SET salary = 10000
WHERE department_id = 99; IF SQL%ROWCOUNT = 0 THEN RAISE
e_my_excep; END IF; EXCEPTION WHEN e_my_excep THEN
DBMS_OUTPUT.PUT_LINE('Message 1'); RAISE e_my_excep;
DBMS_OUTPUT.PUT_LINE('Message 2'); END;
DBMS_OUTPUT.PUT_LINE('Message 3'); EXCEPTION WHEN e_my_excep THEN
DBMS_OUTPUT.PUT_LINE('Message 4'); END; Mark for Review (1) Points

Message 1

Message 3

Message 1

Message 2

Message 1

Message 3 Message 4

Message 1

Message 4 (*)

Correct

19. Which of the following will successfully return a userdefined error message?
Mark for Review (1) Points

RAISE_APPLICATION_ERROR('Error Raised',

22001);

RAISE_APPLICATION_ERROR(-20257,'Error ra

ised'); (*)
RAISE_APPLICATION_ERROR(-22001,'Error Ra

ised');

RAISE_APPLICATION_ERROR('Error Raised',

20257);

Correct

20. User-defined exceptions must be declared explicitly by the programmer, but


then are raised automatically by the Oracle Server. True or False? Mark for
Review (1) Points

True

False (*)

Correct

Section 7 (Answer all questions in this section)

21. A user-defined exception is raised by using: Mark fo

r Review (1) Points

FLAG exception_name;

RAISE exception-name; (*)

PRAGMA EXCEPTION_INIT

RAISE(error_number, exception_name);

Correct

22. Exceptions declared in a block are considered local to that block, and global
to all its sub-blocks. True or False? Mark for Review

(1) Points

True (*)

False

Correct

23. There are no employees in department 75. What will be d isplayed when this
code is executed? 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;
Mark for Review (1) Points

CD

D (*)

B D

None of the above

Correct

24. The following code does not violate any constraints and will not raise an
ORA-02292 error. What will happen when the code is executed? BEGIN
DECLARE e_constraint_violation EXCEPTION; PRAGMA
EXCEPTION_INIT(e_constraint_violation, -2292); BEGIN
DBMS_OUTPUT.PUT_LINE('Inner block message'); END; EXCEPTION WHEN
e_constraint_violation THEN DBMS_OUTPUT.PUT_LINE('Outer block
message'); END; Mark for Review (1) Points

'Inner block message' will be displayed.

The code will fail because the exception is declared in the inner block but is
referenced in the outer block. (*)

'Outer block message' will be displayed.

The code will fail because line 4 should read: PRAGMA EXCEPTION_INIT(-2292,
e_constraint_violation);

Correct

25. Using two nested blocks, a TOO_MANY_ROWS exception is r aised within the
inner block. Which of the following exception handlers will suc cessfully handle
the exception? Mark for Review (1) Points

WHEN TOO_MANY_ROWS in the inner block

WHEN TOO_MANY_ROWS in either block

WHEN OTHERS in either block

WHEN OTHERS in the inner block


All of the above (*)

Correct

26. The following EXCEPTION section is constructed correctl y. True or False?


EXCEPTION WHEN NO_DATA_FOUND OR TOO_MANY_ROWS THEN
statement_1; statement_2; WHEN OTHERS THEN statement_3;
END; Mark for Review (1) Points

True (*)

False

Correct

27. While a PL/SQL block is executing, more than one except ion can occur at
the same time. True or False? Mark for Review (1) Points

True

False (*)

Correct

28. Examine the following code. Why does the exception hand ler 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

You should not use DBMS_OUTPUT.PUT_LINE

in an exception handler.

employee_id 999 does not exist in the em

ployees table.

The exception handler should test for th

e named exception NO_DATA_FOUND. (*)

The exception handler should COMMIT the

transaction.

Correct

29. Which of the following best describes a PL/SQL exceptio n? Mark for Review
(1) Points

A user enters an invalid password while


trying to log on to the database.

An error occurs during execution which d isrupts the normal operation of the
program. (*)

A DML statement does not modify any rows

The programmer makes a spelling mistake

while writiing the PL/SQL code.

Correct

30. Examine the followiing code. Which exception handlers w ould successfully
trap the exception which will be raised when this code is exec uted? (Choose
two.) DECLARE CURSOR emp_curs IS SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE; BEGIN FETCH emp_curs INTO v_emp_rec;
OPEN emp_curs; CLOSE emp_curs; EXCEPTION ... END; Mark for Review (1)
Points

(Choose all correct answers)

WHEN CURSOR_NOT_OPEN

WHEN INVALID_CURSOR (*)

WHEN OTHERS (*)

WHEN NO_DATA_FOUND

WHEN INVALID_FETCH

Correct

Correct 31. How can you retrieve the error code and error message of any
Oracle Ser ver exception? Mark for Review (1) Points

By using the functions SQLCODE and SQLER

RM (*)

By using the functions SQLCODE and SQLER

By using RAISE_APPLICATION_ERROR

By defining an EXCEPTION variable and us

ing PRAGMA EXCEPTION_INIT

Correct
32. Which of the following best describes a user-defined ex ception? Mark for
Review (1) Points

A predefined Oracle Server error such as

NO_DATA_FOUND

A non-predefined Oracle Server error suc

h as ORA-01400

An error which is not automatically rais

ed by the Oracle server (*)

Any error which has an Oracle error numb

er of the form ORA-nnnnn

Correct

33. Examine the following code fragment. At Line A, you wan t to raise an
exception if the fetched salary value is greater than 30000. How c an you do
this? DECLARE v_salary employees.salary%TYPE; BEGIN SELECT salary
INTO v_salary FROM employees WHERE employee_id = 100; IF v_salary
> 30000 THEN -- Line A END IF;

... Mark for Review (1) Points

Test for WHEN VALUE_TOO_HIGH in the exce

ption section.

Use RAISE_APPLICATION_ERROR to raise an

exception explicitly. (*)

Test for WHEN OTHERS in the exception se ction, because WHEN OTHERS traps
all exceptions.

Define an EXCEPTION variable and associa te it with an Oracle Server error


number using PRAGMA EXCEPTION_INIT.

Correct

34. An attempt to update an employee's salary to a negative value will violate a


check constraint and raise an ORA-02290 exception. Which o f the following is a
correct definition of a handler for this exception? Mark for Review (1) Points

DECLARE

e_sal_excep EXCEPTION; PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);


DECLARE PRAGMA EXCEPTION_INIT(e_sal_excep,-02290); e_sal_excep
EXCEPTION;

DECLARE

e_sal_excep EXCEPTION; PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);


(*)

DECLARE

e_sal_excep EXCEPTION; PRAGMA_EXCEPTION_INIT(e_sal_exception,-


02290);

DECLARE

e_sal_excep EXCEPTION; PRAGMA EXCEPTION_INIT(e_sal_excep,02290);

Correct

35. Which of these exceptions would need to be raised expli citly by the PL/SQL
programmer? Mark for Review (1) Points

OTHERS

A SELECT statement returns more than one

row.

A check constraint is violated.

A SQL UPDATE statement does not update a

ny rows. (*)

A row is FETCHed from a cursor while the

cursor is closed.

Correct

Section 8 (Answer all questions in this section)

36. Which of the following are characteristics of PL/SQL st ored procedures?


(Choose three.) Mark for Review (1) Points

(Choose all correct answers)

They are named PL/SQL blocks (*)

They must return exactly one value to th

e calling environment.

They can have an exception section. (*)


They can be invoked from inside a SQL st

atement.

They can accept parameters. (*)

Correct

37. A programmer wants to create a PL/SQL procedure named E MP_PROC. What


will happen when the following code is executed? CREATE OR REPLACE
PROCEDURE emp_proc IS v_salary employees.salary%TYPE; BEGIN
SELECT salary INTO v_salary FROM employees WHERE employee_id = 999;
DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary); END; Mark for Review (1)
Points

The statement will raise a NO_DATA_FOUND exception because employee_id 999


does not exist.

The statement will fail because the last

line of code should be END emp_proc;

The statement will fail because you cann ot declare variables such as v_salary
inside a procedure.

The procedure will be created successful

ly. (*)

The statement will fail because the proc

edure does not have any parameters.

Correct

38. The following are the steps involved in creating, and l ater modifying and re-
creating, a PL/SQL procedure in Application Express. In wh at sequence should
these steps be performed? Retrieve the saved code from "Saved SQL" in SQL
Commands Execute the code to create the procedure Execute the code to re-
create the procedure Click on the "Save" button and save the procedure code
Modify the code in the SQL Commands window Type the procedure code in the
SQL Commands window Mark for Review (1) Points

F,C,A,B,E,D

F,B,D,A,E,C (*)

E,D,F,C,A,B

F,B,D,E,A,C

F,B,C,D,E,A

Correct
39. Which of the following are benefits of using PL/SQL sub programs rather than
anonymous blocks? (Choose three.) Mark for Review (1) Points

(Choose all correct answers)

Easier to write

Better data security (*)

Easier code maintenance (*)

Faster performance (*)

Do not need to declare variables

Correct

40. A stored PL/SQL procedure can be invoked from which of

the following?

A PL/SQL anonymous block Another PL/SQL procedure A calling application


Mark for Review (1) Points

A only

A and B

A and C

A, B and C (*)

B and C

Correct 41. What is another name for a nested subprogram? Mark for Review
(1) Points

Hosted subprogram

Local subprogram (*)

Limited subprogram

Correct

42. A procedure will execute faster if it has at least one parameter. Mark for
Review (1) Points

True

False (*)

Correct
43. Which of the following can NOT be used as the datatype of a procedure
parameter? Mark for Review (1) Points

A non-SQL datatype such as BOOLEAN

The name of another procedure (*)

A large object datatype such as CLOB

A PLSQL record defined using %ROWTYPE

Correct

44. Which of the following best describes how an IN paramet er affects a


procedure? Mark for Review

(1) Points

It describes the order in which the proc

edure's statements should be executed.

It describes which parts of the procedur

e's code are optional or conditional.

It makes the procedure execute faster.

It passes a value into the procedure whe

n the procedure is invoked. (*)

It allows complex calculations to be exe

cuted inside the procedure.

Correct

45. You have created the following procedure: CREATE OR REPLACE PROCEDURE
double_it (p_param IN OUT NUMBER) IS BEGIN p_param := p_param * 2;
END;

Which of the following anonymous blocks invokes this procedure successfully?


Mark for Review (1) Points

BEGIN

EXECUTE double_it(20); END;

BEGIN

SELECT double_it(20) FROM DUAL; END;

DECLARE
v_result NUMBER(6); BEGIN v_result := double_it(20); END;

DECLARE

v_result NUMBER(6) := 20; BEGIN double_it(v_result); END; (*)

BEGIN

double_it(20); END;

Correct

46. Which of the following statements about actual paramete rs is NOT true?
Mark for Review (1) Points

An actual parameter is declared in the c alling environment, not in the called


procedure

An actual parameter must be the name of

a variable (*)

An actual parameter can have a Boolean d

atatype

The datatypes of an actual parameter and

its formal parameter must be compatible

An actual parameter can have a TIMESTAMP

datatype

Correct

47. Which parameter mode is the default? Mark for Review

(1) Points

IN (*)

OUT

NUMBER

VARIABLE

CONSTANT

Correct

48. Procedure SOMEPROC has five parameters named A, B, C, D , E in that order.


The procedure was called as follows: SOMEPROC(10,20,D=>50);
How was parameter D referenced? Mark for Review (1) Points

Positionally

Named (*)

A combination of positionally and named

A combination of named and defaulted

Defaulted

Correct

49. Procedure SOMEPROC has five parameters named A, B, C, D , E in that order.


The procedure was called as follows: SOMEPROC(10,20,D=>50);

How was parameter B referenced? Mark for Review (1) Points

Positional (*)

Named

A combination of positionally and named

A combination of named and defaulted

Defaulted

Correct

50. What are the type of parameter modes? Mark for Review

(1) Points

CHARACTER, NUMBER, DATE, BOOLEAN

CONSTANT, VARIABLE, DEFAULT

LOCAL, GLOBAL, BOTH

IN, OUT, IN OUT (*)

Correct

TEST 2 ......................................................................... ...........

1. What is the name of the column used to identify the PLSQL_OPTIMIZE_LEVE L


in the data dictionary? Mark for Review (1) Points

OPTIMIZE_LEVEL

PLSQL_OPTIMIZE_LEVEL (*)

PLSQL_CODE_TYPE
PLSQL_LEVEL

USER_PLSQL_OPTIMIZE

Correct

2. To determine the current setting for PLSQL_OPTIMIZE_LEV EL, query the data
dictionary view USER_PLSQL_OBJECTS_SETTING. True or False? Mark for Review
(1) Points

True

False (*)

Correct

3. Identify examples of benefits of using PLSQL_OPTIMIZE_L EVEL. (Choose


three) Mark for Review (1) Points

(Choose all correct answers)

Modify source code to optimize frequentl

y-used elements at the top.

Control what PL/SQL does with useless co

de. (*)

Backward compatible with previous versio

ns of the Oracle database. (*)

Separating compiled code so that separat e units may be repeated as needed.

Copy compiled code from one subprogram i

nto another subprogram. (*)

Correct

4. What does the following statement do?


DBMS_WARNING.ADD_WARNING_SETTING_CAT('PERFORMANCE','ENABLE','SESSIO
N'); Mark for Review (1) Points

Enables the PERFORMANCE warning category , setting other category settings to


disabled.

Enables the PERFORMANCE warning category , leaving other category settings


unchanged.

Add the PERFORMANCE warning category int

o a PL/SQL variable.
Disables all warning categories, then en

ables the PERFORMANCE category.

Enables the PERFORMANCE warning category , leaving other category settings


unchanged, for the current session. (*)

Correct

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


DBMS_WARNING.SET_WARNING_SETTING_STRING
('ENABLE:SEVERE','SESSION');

and

ALTER SESSION SET PLSQL_WARNINGS = 'ENABLE:SEVERE'; Mark for Review (1)


Points

True

False (*)

Correct

6. In the USER_ERRORS data dictionary view, if an error is prefixed with


"Warning," the command completes but has a side effect the user n eeds to
know about. For all other errors, the command terminates abnormally. Tru e or
False? Mark for Review (1) Points

True (*)

False

Correct

7. Which is NOT a benefit of obfuscation? Mark fo

r Review (1) Points

Source code is not loaded in the data di

ctionary.

Source code is hidden from all users.

Source code is visible to the owner. (*)

Protection for intellectual property is

provided.

Correct
8. What are the two methods for obfuscating PL/SQL subprog rams? (Choose
two) Mark for Review (1) Points

(Choose all correct answers)

DBMS_DDL.CREATE_WRAPPED (*)

DBMS_DDL.WRAP

DBMS_DML.CREATE_WRAPPED

PL/SQL wrapper utility program (*)

SQL wrapper utility program

Correct

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


IN argument with data type CLOB to allow for any size program. True or False?
Mark for Review (1) Points

True

False (*)

Correct

10. Conditional compilation allows you to determine what co de will be compiled


based on select criteria you specify using inquiry directive s. True or False? Mark
for Review (1) Points

True

False (*)

Correct

11. Identify some benefits of using conditional compilation. (Choose two) Mark
for Review (1) Points

(Choose all correct answers)

Use new features with the latest databas e release and disable them with older
database versions (*)

Speed up the compilation time of a lengt

hy PL/SQL subprogram.

Determine initialization values during s

tart up of a database session.

Activate debugging or tracing statements in the development environment (*)


Correct

12. How would you determine the current Oracle database ver sion? Mark for
Review (1) Points

DBMS_DB_VERSION.RELEASE

DBMS_DB_VERSION.VERSION (*)

DBMS_DB_VERSION.VER_LE_10

DBMS_DB_VERSION.VER_LE_11

Correct

Section 14 (Answer all questions in this section)

13. Function FETCH_EMP references the EMPLOYEES table. The table is modified
by: ALTER TABLE employees ADD (resume CLOB); When will the ORACLE server
try to recompile FETCH_EMP automatically? Mark fo r Review (1) Points

When the command ALTER FUNCTION fetch_em

p COMPILE; is executed

The next time a user session invokes FET

CH_EMP (*)

When the RESUME column is dropped from t

he EMPLOYEES table

When FETCH_EMP is dropped and recreated

Correct

14. Package EMPPACK contains a public procedure GET_EMP, wh ich contains a


reference to the EMPLOYEES table. Procedure CALL_EMP invokes EMPP
ACK.GET_EMP. The following SQL statement is executed: ALTER TABLE
employees ADD (gender CHAR(1));

Which one of the following statements is true? Mark for Review (1) Points

The specification and body of EMPPACK ar e invalidated, but CALL_EMP remains


valid.

The body of EMPPACK is invalidated, but

the specification remains valid. (*)

EMPPACK.GET_EMP is invalidated, but othe

r procedures in EMPPACK remain valid.


Nothing is invalidated because the PL/SQ L code does not reference the GENDER
column.

Correct

15. Which of the following will display dependency informat ion which has been
generated by executing the DEPTREE_FILL procedure? (Choose tw o.) Mark for
Review (1) Points

(Choose all correct answers)

The USER_DEPENDENCIES view

The DEPTREE view (*)

The UTLDTREE script

The DISPLAY_DEPTREE view

The IDEPTREE view (*)

Correct

16. The PL/SQL variable V_LAST_NAME is used to store fetche d values of the
LAST_NAME column of the EMPLOYEES table. To minimize dependency failures,
the variable should be declared as: v_last_name VARCHAR2(25);

True or False? Mark for Review

(1) Points

True

False (*)

Correct

17. A SELECT from the DEPTREE table displays table LOCATION S at nested level
0 and procedure LOCPROC at nested level 2. This shows that LOC PROC is
directly dependent on LOCATIONS. True or False? Mark for Review

(1) Points

True

False (*)

Correct

18. User BOB wants to know which objects reference his DEPA RTMENTS table.
Which of the following must he execute to populate the DEPTREE_TE MPTAB
table? Mark for Review (1) Points

BEGIN
utldtree('DEPARTMENTS'); END;

BEGIN deptree_fill('TABLE','BOB','DEPARTMENTS'); END; (*)

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

BEGIN ideptree('TABLE','BOB','DEPARTMENTS'); END;

Correct

19. When a table is dropped, all PL/SQL subprograms that re ference the table
are automatically dropped. True or False? Mark for Review

(1) Points

True

False (*)

Correct

20. Which of the following will display the number of inval id package bodies in
your schema? Mark for Review (1) Points

SELECT COUNT(*) FROM user_objects

WHERE object_type = 'PACKAGE BODY' AND status = 'INVALID'; (*)

SELECT COUNT(*) FROM user_dependencies

WHERE type = 'PACKAGE BODY' AND status = 'INVALID';

SELECT COUNT(*) FROM user_packages

WHERE status = 'INVALID';

SELECT COUNT(*) FROM user_objects

WHERE object_type LIKE 'PACKAGE%' AND status = 'INVALID';

Correct 21. Procedure B has its local variable emp_number changed to


emp_name. The data type of emp_id is changed from number to integer. It is
compiled successful ly. In Signature Mode, Procedure A, which is dependent on
remote Procedure B, wi ll compile and execute successfully. True or False? Mark
for Review (1) Points

True (*)

False

Correct

22. Procedure B has the ZERO_DIVIDE pre-defined exception a dded to its


EXCEPTION section. It is compiled successfully. In Timestamp Mode, P rocedure A,
which is dependent on remote Procedure B, will compile and execute s
uccessfully. True or False? Mark for Review (1) Points

True

False (*)

Correct

23. A change in a remote referenced subprogram is automatic

ally recorded as invalid if its base object changes and that new status is relay ed
to the dependent object's status and automatically marked as invalid. True or
False? Mark for Review (1) Points

True

False (*)

Correct

24. In this scenario, the following status is given for each

procedure: Procedure A is local and has a time stamp of 10 AM Procedure B is


remote and has a local and remote time stamp of 10:30 AM

In Timestamp Mode, Procedure A, which is dependent on Procedure B, will


execute successfully at 11 AM. True or False? Mark for Review (1) Points

True (*)

False

Correct

25. Which command changes the dependency mode to SIGNATURE in the


current session? Mark for Review (1) Points

ALTER SESSION MAKE REMOTE_DEPENDENCIES_M

ODE = SIGNATURE

ALTER SYSTEM MAKE REMOTE_DEPENDENCIES_MO

DE = SIGNATURE

ALTER SESSION SET REMOTE_DEPENDENCIES_MO

DE = SIGNATURE (*)

ALTER SYSTEM SET REMOTE_DEPENDENCIES_MOD

E = SIGNATURE

Correc
PLSQL Final Exam Semester 1 - Part II

1. A programmer creates a PL/SQL subprogram which is compiled andstored in the database.


Two separate users then execute an applicationwhich invokes this subprogram four times.
How many times must the
subprogram be recompiled? (1) Points

Twice
Four times
None (*)
Eight times
Once

2. Which of the following are benefits of using PL/SQLsubprograms rather than anonymous
blocks? (Choose three.) (1) Points
(Choose all correct answers)

Easier to write
Better data security (*)
Easier code maintenance (*)
Faster performance (*)
Do not need to declare variables

3. A programmer wants to create a PL/SQL procedure namedEMP_PROC. What will happen


when the following code is executed?
CREATE OR REPLACE PROCEDURE emp_proc ISv_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employeesWHERE employee_id = 999;
DBMS_OUTPUT.PUT_LINE('The salary is: ' || v_salary);
END;(1) Points

The statement will raise a NO_DATA_FOUND exception because employee_id 999 does not
exist.
The statement will fail because the last line of code should be END emp_proc; of code should
be END emp_proc;
The statement will fail because you cannotdeclare variables such as v_salary inside a
procedure.
The procedure will be created successfully.(*)
The statement will fail because the proceduredoes not have any parameters.

4. Which of the following are characteristics of PL/SQLstored procedures? (Choose three.)


(1) Points (Choose all correct answers)

They are named PL/SQL blocks (*)


They must return exactly one value to thecalling environment.
They can have an exception section. (*)
They can be invoked from inside a SQLstatement.
They can accept parameters. (*)

5. The following are the steps involved in creating, andlater modifying and re-creating, a
PL/SQL procedure in
pplicationExpress. In what sequence should these steps be performed?
(1) Points
F,C,A,B,E,D
F,B,D,A,E,C (*)
E,D,F,C,A,B
F,B,D,E,A,C
F,B,C,D,E,A

6. A PL/SQL procedure named MYPROC has already been created and storedin the database.
Which of the following will successfully re-create the procedure after some changes have
been made to the code? (1) Points
CREATE PROCEDURE myproc IS ...
CREATE OR REPLACE PROCEDURE myproc IS ....(*)
UPDATE PROCEDURE myproc IS ...
ALTER PROCEDURE myproc IS ...
None of the above, because the procedure mustbe dropped before it can be re-created.

7. The following procedure has been created:


CREATE OR REPLACE PROCEDURE myproc
(A IN NUMBER := 20,
B IN NUMBER,
C IN NUMBER DEFAULT 30)
IS .....
Which of the following will invoke the procedure correctly? (1) Points

myproc(40);
myproc(10, B => 30, 50);
myproc(C => 25);
All of the above
None of the above (*)

8. Suppose you set up a parameter with an explicit IN mode. What is true about that
parameter? (1) Points

It must have a DEFAULT value.


It cannot have a DEFAULT value.
It acts like a constant (its value cannot bechanged inside the subprogram). (*)
nt (its value cannot bechanged inside the subprogram). (*)
It must be the same type as the matching OUTparameter.
It inherits its type from the matching OUTparameter.

9. Procedure SOMEPROC has five parameters named A, B, C, D, E in that order. The


procedure was called as follows:
SOMEPROC(10,20,D=>50); How was parameter D referenced? (1) Points
Positionally
Named (*)
A combination of positionally and named
A combination of named and defaulted
Defaulted

10. Procedure SOMEPROC has five parameters named A, B, C, D,E in that order. The
procedure was called as follows:
SOMEPROC(10,20,D=>50); How was parameter B referenced? (1) Points
Positional (*)
Named
A combination of positionally and named
A combination of named and defaulted
Defaulted

11. Using nested blocks, when is it necessary to label the outer block?. (1) Points

You must always label the outer block.


You must always label both blocks.
You must label the outer block when two variables with the same name are declared, one in
each block.
You must label the outer block when two variables with the same name are declared and you
need to reference theouter block's variable within the inner block. (*)
Block labels are just comments and are therefore recommended but never needed.

12. Which of the following will display the value 'Smith'? (1) Points
<<outer>>
DECLARE
v_name VARCHAR2(10) := 'Smith';
BEGIN
DECLARE
v_name VARCHAR2(10) := 'Jones';
BEGIN
DBMS_OUTPUT.PUT_LINE(v_name);
END;
END;

<<outer>>
DECLARE
v_name VARCHAR2(10) := 'Smith';
BEGIN
DECLARE
v_name VARCHAR2(10) := 'Jones';
BEGIN
DBMS_OUTPUT.PUT_LINE(<<outer>>.v_name);
END;
END;

<<outer>>
DECLARE
v_name VARCHAR2(10) := 'Smith';
BEGIN
DECLARE
v_name VARCHAR2(10) := 'Jones';
BEGIN
DBMS_OUTPUT.PUT_LINE(outer.v_name);
END;
END;(*)

<<outer>>
DECLARE
v_name VARCHAR2(10) := 'Smith';

BEGIN
<<inner>>
DECLARE

v_name VARCHAR2(10) := 'Jones';


BEGIN
DBMS_OUTPUT.PUT_LINE(v_name);
END;
END;

13. The following code will execute correctly. True orFalse?


DECLARE
v_myvar1 NUMBER;
BEGIN
DECLARE
v_myvar2 NUMBER;
BEGIN

v_myvar1 := 100;
END;
v_myvar2 := 100; v END; (1) Points

True
False (*)

14. What will happen when the following code is executed?

BEGIN --outer block


DECLARE --inner block
CURSOR emp_curs IS SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE;

BEGIN
OPEN emp_curs;
LOOP

FETCH emp_curs INTO v_emp_rec;


DBMS_OUTPUT.PUT_LINE(v_emp_rec.salary);
END LOOP;
END;
CLOSE emp_curs;

END; (1) Points

The code will fail because you cannot declarea cursor in an inner block. a cursor in an inner
block.
The code will fail because the cursor is declared in the inner block but is referenced in the
outer block. (*)
The code will execute successfully anddisplay all the employees' salaries.
The code will execute forever because there is no statement to EXIT from the loop.

15. What will be displayed when the following code isexecuted?


<<outer>>
DECLARE
v_myvar NUMBER;

BEGIN
v_myvar := 10;
DECLARE

v_myvar NUMBER := 200;

BEGIN
outer.v_myvar := 20;
v_myvar := v_myvar / 0; --this raises a ZERO_DIVIDE error
outer.v_myvar := 30;

END;
v_myvar := 40;
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE(v_myvar);
END; (1) Points

10
20 (*)
30
40
200

16. What will happen when the following code is executed?

DECLARE
e_excep1 EXCEPTION;
e_excep2 EXCEPTION;

BEGIN
RAISE e_excep1;
EXCEPTION

WHEN e_excep1 THEN BEGIN RAISE e_excep2;


END;
END; (1) Points

It will fail to compile because you cannothave a subblock inside an exception section.
It will fail to compile because e_excep1 isout of scope in the subblock.
It will fail to compile because you cannotdeclare more than one exception in the same block.
It will compile successfully and return anunhandled e_excep2 to the calling environment. (*)

17. Consider the following function:


CREATE FUNCTION ADD_EM
(a NUMBER := 1,
b NUMBER := 2 )
RETURN NUMBER

IS BEGIN
RETURN (a+b);
END ADD_EM;

Which one of the following blocks will NOT work correctly? (1) Points
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;

DECLARE
x NUMBER;
BEGIN BEGIN

x:= add_em;
END;

None of them will work.

18. A function must have at least one IN parameter, and must


return exactly one value. (1) Points

True
False (*)

19. Why will this function not compile correctly?


CREATE FUNCTION bad_one
IS BEGIN
RETURN NULL;
END bad_one; (1) Points

You cannot RETURN a NULL.


You must declare the type of the RETURNbefore the IS. (*)
You must have at least one IN parameter.
You must code CREATE OR REPLACE, not CREATE.
The body of the function must contain atleast one executable statement (as well as
RETURN).

20. A function named MYFUNC has been created. This function accepts one IN parameter of
datatype VARCHAR2 and returns a NUMBER.
You want to invoke the function within the following anonymous block:
DECLARE
v_var1 NUMBER(6,2);
BEGIN
--Line A
END;

What could be coded at Liine A? (1) Points

myfunc('Crocodile') := v_var1;
myfunc(v_var1) := 'Crocodile';
myfunc(v_var1, 'Crocodile');
v_var1 := myfunc('Crocodile'); (*)
myfunc('Crocodile', v_var1);

21. What is wrong with the following code?

CREATE FUNCTION badfunc


(p_param NUMBER(4))
RETURN BOOLEAN
IS BEGIN
RETURN (p_param > 10);

a precision or scale. It must be NUMBER, not NUMBER(4). (*)

END badfunc;
(1) Points
Mark for Review
P_PARAM must be declared AFTER the RETURN
clause.
P_PARAM must have a default value.
The datatype of the IN parameter cannot have

RETURN (p_param > 10); is wrong because youcannot return an expression.

The NUMBER datatype must have a scale as wellas a precision.

22. Which of the following is a difference between a procedure and a function? (1) Points

Functions cannot be nested; procedures can benested to at least 8 levels.


A procedure can have default values forparameters, while a function cannot.
An explicit cursor can be declared in a procedure, but not in a function.
A function cannot be used within a SQLstatement; a procedure can be used within SQL.
A function must return a value, a proceduremay or may not. (*) may or may not. (*)

23. You want to remove the procedure NO_NEED from yourschema. You execute:
DROP PROCEDURE no_need;
Which Data Dictionary views are updated automatically? (1) Points

USER_PROCEDURES
USER_OBJECTS
USER_SOURCE
All of the above. (*)
None of the above.

24. Examine the following code: CREATE PROCEDURE parent


IS BEGIN
child1;
child2;

EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END parent;

Neither CHILD1 nor CHILD2 has an exception handler.


When PARENT is invoked, CHILD1 raises a NO_DATA_FOUND exception. Whathappens
next? (1) Points

PARENT handles the exception, then CHILD1continues to execute.


CHILD1 ends abruptly. PARENT handles theexception and then ends. CHILD2 does not
execute. (*)
CHILD1 ends abruptly, PARENT handles theexception, then CHILD2 executes.
CHILD1 ends abruptly, PARENT also endsabruptly and returns an unhandled exception.
PARENT does not compile because you cannotuse NULL; in an exception handler.

25. The following code shows the dependencies between threeprocedures:


CREATE PROCEDURE parent

IS BEGIN
child1;
child2;

END parent;
You now try to execute:

DROP PROCEDURE child2;


What happens? (1) Points

You cannot drop CHILD2 because PARENT isdependent on it.


CHILD2 is dropped successfully. PARENT andCHILD1 are both marked INVALID.
The database automatically drops PARENT aswell.
CHILD2 is dropped successfully. PARENT ismarked INVALID. CHILD1 is still valid. (*)
The database automatically drops CHILD1 aswell.

26. User BOB creates procedure MYPROC using the default Definer'sRights. BOB then
executes:

GRANT EXECUTE ON bob.myproc TO ted;


When TED invokes BOB.MYPROC, whose privileges are checked? (1) Points

TED's privileges
PUBLIC's privileges
SYSTEM's privileges
BOB's privileges (*)
ORACLE's privileges

27. How do you specify that you want a procedure MYPROCA touse "Definer's Rights"? (1)
Points

CREATE OR REPLACE PROCEDURE myprocaAUTHID CURRENT_USER IS...


AUTHID CURRENT_USER IS...
CREATE OR REPLACE PROCEDURE myprocaAUTHID OWNER IS...
GRANT DEFINER TO myprocA;
ALTER PROCEDURE myproca TO DEFINER;
Definer's Rights are the default, thereforeno extra code or commands are needed. (*)

28. You have created procedure MYPROC with a singleparameter PARM1 NUMBER. Now
you want to add a second parameter to theprocedure. Which of the following will change the
procedure successfully? (1) Points

ALTER PROCEDURE myproc ADD (parm2 NUMBER);

The procedure cannot be modified. Once aprocedure has been created, the number of
parameters cannot be changed.
CREATE OR REPLACE PROCEDURE someproc(parm1 NUMBER, parm2 NUMBER);

(You do not need to repeat the detailed code of the procedure, only theheader)
REPLACE PROCEDURE someproc(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ...
CREATE OR REPLACE PROCEDURE MYPROC
(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ... (*)

29. Which of the following statements about actualparameters is NOT true? (1) Points

An actual parameter is declared in thecalling environment, not in the called procedure


An actual parameter must be the name of a variable (*) e of a variable (*)
An actual parameter can have a Booleandatatype
The datatypes of an actual parameter and itsformal parameter must be compatible
An actual parameter can have a TIMESTAMPdatatype

30. A procedure will execute faster if it has at least oneparameter. (1) Points

True
False (*)

31. Which of the followingis NOT correct coding for a procedure parameter? (1) Points

(p_param IN VARCHAR2)
(p_param VARCHAR2)
(p_param VARCHAR2(50)) (*)
(p_param employees.last_name%TYPE)
(p_param IN OUT VARCHAR2)

32. You want to create a procedure named SOMEPROC whichaccepts a single parameter
named SOMEPARM. The parameter can be up to 100characters long. Which of the following
is correct syntax to do this? (1) Points

CREATE PROCEDURE someproc


(someparm varchar2)
IS
BEGIN ...
(*)

CREATE PROCEDURE someproc


(someparm varchar2(100) )
IS
BEGIN... BEGIN...

CREATE PROCEDURE someprocIS


(someparm VARCHAR2)
BEGIN...

CREATE PROCEDURE someprocsomeparm varchar2(100);


IS
BEGIN...
CREATE PROCEDURE someproc
(someparm 100)
IS
BEGIN ...

33. Which of the following best describes how an INparameter affects a procedure? (1) Points

It describes the order in which the procedure's statements should be executed.


It describes which parts of the procedure'scode are optional or conditional.
It makes the procedure execute faster.
It passes a value into the procedure when theprocedure is invoked. (*)
It allows complex calculations to be executedinside the procedure.

34. Examine the following code fragment. At Line A, you wantto raise an exception if the
fetched salary value is greater than 30000. How can you do this?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary FROM employeesWHERE employee_id = 100;
IF v_salary > 30000 THEN--Line A
END IF;
...
(1) Points

Test for WHEN VALUE_TOO_HIGH in the exceptionsection.


Use RAISE_APPLICATION_ERROR to raise an exception explicitly. (*)
Test for WHEN OTHERS in the exceptionsection, because WHEN OTHERS traps all
exceptions.
Define an EXCEPTION variable and associate it with an Oracle Server error number using
PRAGMA EXCEPTION_INIT.

35. An attempt to insert a null value into a NOT NULL tablecolumn raises an ORA-01400
exception. How can you code an exceptionhandler to trap this exception? (1) Points

Test for WHEN ORA-1400 in the exceptionsection.

Declare a variable e_null_excep of typeEXCEPTION, associate it with ORA-01400 using a


PRAGMA directive, and testfor WHEN e_null_excep in the exception section. (*)

Declare a variable e_null_excep of typeVARCHAR2, associate it with ORA-01400 using a


PRAGMA directive, and testfor WHEN e_null_excep in the exception section.

Declare a variable as follows: e_null_excepEXCEPTION := -01400; Then test for WHEN


e_null_excep in the exceptionsection.

36.Examine the followiing code. Which exception handlers wouldsuccessfully trap the
exception which will be raised when this code isexecuted? (Choose two.)

DECLARE
CURSOR emp_curs IS SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE;
BEGIN
FETCH emp_curs INTO v_emp_rec;
OPEN emp_curs;
CLOSE emp_curs;
EXCEPTION ...
END;
(1) Points (Choose all correct answers)

WHEN CURSOR_NOT_OPEN
WHEN INVALID_CURSOR (*)
WHEN OTHERS (*)
WHEN NO_DATA_FOUND
WHEN INVALID_FETCH

37. Which of these exceptions would need to be raisedexplicitly by the PL/SQL programmer?
(1) Points
OTHERS
A SELECT statement returns more than one row.
A check constraint is violated.
A SQL UPDATE statement does not update any rows. (*)
A row is FETCHed from a cursor while the cursor is closed.

38. How can you retrieve the error code and error message ofany Oracle Server exception?
(1) Points
By using the functions SQLCODE and SQLERRM (*)
By using the functions SQLCODE and SQLERR
By using RAISE_APPLICATION_ERROR
By defining an EXCEPTION variable and using PRAGMA EXCEPTION_INIT

39. Examine the following code. What message or messageswill be displayed when this code
is executed?
DECLARE
v_last_name employees.last_name%TYPE;
v_number NUMBER := 27;

BEGIN

v_number := v_number / 0;
SELECT last_name INTO v_last_name FROM employeesWHERE employee_id = 999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No rows were found');
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Attempt to divide by zero');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END; Mark for Review
SELECT last_name INTO v_last_name FROM employeesWHERE employee_id = 999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No rows were found');
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Attempt to divide by zero');
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('An error occurred');
END;
(1) Points

No rows were found


Attempt to divide by zero (*)
Attempt to divide by zero No rows were found
An error occurred
No message will be displayed

40. In which DML statements can user-defined functions be


used? (1) Points

INSERT and UPDATE, but not DELETE.


INSERT only.
All DML statements. (*)
UPDATE only
DELETE only

41. Which one of the following statements about user-defined functions is NOT true? (1)
Points

They can execute spell-checking routines.


They can be used inside SQL statements.
They can be combined (nested) together, similar to nesting system functions, for example
INITCAP(SUBSTR( .....)).
They can return a TIMESTAMP datatype.
They can allow you to COMMIT from inside aSELECT statement. (*)

42. Which of the following are NOT allowed in a functionwhich is used inside a SQL
statement which updates the EMPLOYEES table? (Choose two). (1) Points (Choose all
correct answers)

SELECT .... FROM departments ....;


COMMIT; (*)
A RETURN statement.
DDL statements such as CREATE or ALTER. (*)
A WHEN OTHERS exception handler.

43. Which of the following is NOT an advantage of includingan exception handler in a


PL/SQL block? (1) Points

Protects the database from errors


Code is more readable because error-handlingroutines can be written in the same block in
which the error occurred
Prevents errors from occurring (*)
Avoids costly and time-consuming correctionof mistakes

44. While a PL/SQL block is executing, more than oneexception can occur at the same time.
True or False? (1) Points

True
False (*)

45. The following EXCEPTION section is constructedcorrectly. True or False?

EXCEPTION

WHEN NO_DATA_FOUND OR TOO_MANY_ROWS

THEN statement_1;

statement_2;

WHEN OTHERS

THEN statement_3;
END;
(1) Points

True (*)
False

46. Which of the followingare good practice guidelines for exception handling? (Choose
three.) (1) Points (Choose all correct answers)

Test your code with different combinations ofdata to see what potential errors can happen. (*)
Use an exception handler whenever there is any possibility of an error occurring. (*)
Include a WHEN OTHERS handler as the first handler in the exception section.
Allow exceptions to propagate back to thecalling environment.
Handle specific named exceptions wherepossible, instead of relying on WHEN OTHERS. (*)

47. A user-defined exception must be declared as a variableof data type EXCEPTION. True
or False? (1) Points

True (*)
False

48. A user-defined exception can be raised:


A. In the declaration section
B. In the executable section
C. In the exception section Mark for Review
(1) Points

B
C
A and B
B and C (*)
A and C

49. User-defined exceptions must be declared explicitly bythe programmer, but then are
raised automatically by the Oracle Server. True or False? (1) Points

True
False (*)

50. Department-id 99 does not exist. What will be displayedwhen the following code is
executed?
DECLARE
v_deptname departments.department_name%TYPE;
BEGIN
SELECT department_name INTO v_deptnameFROM departments WHERE department_id =
99;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20201,'Department does not exist');
END;
(1) Points

ORA-01403: No Data Found ORA-20201:


Department does not exist
ORA-01403: No Data Found
ORA-20201: Department does not exist (*)
None of the above
SECTION 9 LESSON 1 1. What will happen when the following subprogram is
compiled?

PROCEDURE at_proc IS PRAGMA AUTONOMOUS_TRANSACTION; dept_id


NUMBER := 90; BEGIN UPDATE ... INSERT ... END at_proc;

Mark for Review (1) Points The subprogram will fail because it is missing AUTHID
CURRENT_USER before IS. The autonomous transaction subprogram will fail
because it must include COMMIT or ROLLBACK. (*) The compilation will fail
because a semicolon after AUTONOMOUS_TRANSACTION is not needed. The
program will compile successfully. Incorrect. Refer to Section 9 Lesson 6. 2. To
create a function successfully, the following steps should be performed:

A Re-execute the code until it compiles correctly B Write the code containing
the CREATE or REPLACE FUNCTION followed by the function code C Test the
function from a SQL statement or an anonymous block D If the function fails to
compile, correct the errors E Load the code into Application Express F Execute
the code in Application Express

What is the correct order to perform these steps?


Mark for Review (1) Points B,E,F,D,A,C (*) D,B,E,F,A,C B,C,E,F,D,A A,B,E,F,D,C
Correct 3. An autonomous transaction subprogram may be in the same package
as the calling subprogram or may be in a separate subprogram. True or False?
Mark for Review (1) Points True False (*) Incorrect. Refer to Section 9 Lesson 6.

4. Which of the following is found in a function and not a procedure? Mark for
Review (1) Points An exception section. IN parameters. Local variables in the
IS/AS section. Return statement in the header. (*) Correct 5. The following
function has been created:

CREATE OR REPLACE FUNCTION find_sal (p_emp_id IN employees.employee_id


%TYPE) RETURN NUMBER IS ...

We want to invoke this function from the following anonymous block:

DECLARE v_mynum NUMBER(6,2); v_mydate DATE; BEGIN ... Line A END;

Which of the following would you include at Line A?

Mark for Review (1) Points find_sal(100,v_mynum); v_mynum := find_sal(100); (*)


v_mydate := find_sal(100); find_sal(v_mynum,100); Correct 6. You have created
a function called GET_COUNTRY_NAME which accepts a country_id as an IN
parameter and returns the name of the country. Which one of the following calls
to the function will NOT work? Mark for Review (1) Points v_name :=
get_country_name(100); DBMS_OUTPUT.PUT_LINE(get_country_name(100));
SELECT get_country_name(100) FROM dual; BEGIN get_country_name(100,
v_name); END; (*) Correct 7. What is wrong with the following code? CREATE
FUNCTION annual_comp (sal employees.salary %TYPE, comm_pct IN
employees.commission%TYPE) RETURN NUMBER(5,2) IS RETURN (sal*12) +
NVL(comm_pct,0)*12*sal; END annual_comp; Mark for Review (1) Points

The sal parameter should specify the IN keyword. The RETURN NUMBER has a
scale and precision. (*) There should be parentheses (brackets) around
NVL(comm_pct,0)*12*sal The END; statement should not include the function
name. Correct 8. Function MYFUNC1 has been created, but has failed to compile
because it contains syntax errors. We now try to create procedure MYPROC1
which invokes this function. Which of the following statements is true? Mark for
Review (1) Points MYPROC1 will compile correctly, but will fail when it is
executed. MYPROC1 will compile and execute succesfully. MYPROC1 will fail to
compile because the function is invalid. (*) MYPROC1 will compile and execute
successfully, except that the call to MYFUNC1 will be treated as a comment and
ignored. Correct 9. Based on the following function definition: Create function
annual_comp (sal employees.salary %type, comm_pct In employees.commission
%type) ... Which one of the following is an incorrect call for annual_comp? Mark
for Review (1) Points Execute dbms_output.put_line(annual_comp (1000,.2))
Select employee_id, annual_comp(salary, commission_pct) from employees;
Declare Ann_comp number (6,2); Begin ... Ann_comp :=
annual_comp(1000,.2); ... End; Select employee_id, annual_comp(salary) from
employees; (*) Correct 10. When using Invoker's rights, the invoker needs
privileges on the database objects referenced within the subprogram, as well as
GRANT privilege on the procedure. True or False? Mark for Review (1) Points True
False (*) Incorrect. Refer to Section 9 Lesson 6. 11. Procedure p1 has a single
OUT parameter of type DATE. Function f1 returns a DATE. What is the difference
between p1 and f1? Mark for Review (1) Points p1 can be invoked from an
anonymous block but f1 cannot f1 can be used within a SQL statement but p1
cannot (*) p1 can have as many IN parameters as needed but f1 cannot have
more than two IN parameters There is no difference because they both return a
single value of the same datatype Incorrect. Refer to Section 9 Lesson 1. 12. A
PL/SQL function can have IN OUT parameters. True or False? Mark for Review (1)
Points

True False (*) Correct 13. A stored function: Mark for Review (1) Points must have
at least one IN parameter. cannot be called in a SQL statement. must return one
and only one value. (*) is called as a standalone executable statement. Correct
14. Function GET_JOB accepts an employee id as input and returns that
employee's job id. Which of the following calls to the function will NOT work?
Mark for Review (1) Points DBMS_OUTPUT.PUT_LINE(get_job(100)); IF
get_job(100) = 'IT_PROG' THEN ... get_job(100,v_job_id); (*) v_job_id :=
get_job(100); Correct 15. CREATE FUNCTION get_sal (p_id
employees.employee_id%TYPE)) RETURN number IS v_sal employees.salary
%TYPE := 0; BEGIN SELECT salary INTO v_sal FROM employees WHERE
employee_id = p_id; RETURN v_sal; END get_sal;

Which variable is passed to the function and which variable is returned from the
function?

Mark for Review (1) Points GET_SAL is passed and V_SAL is returned. SALARY is
passed and P_ID is returned. EMPLOYEE_ID is passed and SALARY is returned.
P_ID is passed and V_SAL is returned. (*) Correct

LESSON 2

1. Function DOUBLE_SAL has been created as follows: CREATE OR REPLACE


FUNCTION 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 work? Mark for Review (1) Points SELECT * FROM employees WHERE
double_sal(salary) > 20000; SELECT * FROM employees ORDER BY
double_sal(salary) DESC; UPDATE employees SET salary = double_sal(salary);
SELECT last_name, double_sal(salary) FROM employees; None of the above; they
will all work (*) Correct 2. User-defined functions can extend the power of SQL
statements where Oracle does not provide ready-made functions such as UPPER
and LOWER. True or False? Mark for Review (1) Points True (*) False Correct 3. The
following function has been created:

CREATE OR REPLACE FUNCTION upd_dept (p_dept_id IN


departments.department_id%TYPE) RETURN NUMBER IS BEGIN UPDATE
departments SET department_name = 'Accounting' WHERE department_id =
p_dept_id; RETURN p_dept_id; END;
Which of the following will execute successfully?

Mark for Review (1) Points DELETE FROM departments WHERE department_id =
upd_dept(department_id); SELECT upd_dept(department_id) FROM employees;
DELETE FROM employees WHERE department_id = upd_dept(80);

(*) SELECT upd_dept(80) FROM dual; Incorrect. Refer to Section 9 Lesson 2. 4.


Which of the following is NOT a benefit of user-defined functions? Mark for
Review (1) Points They can add business rules to the database and can be reused
many times.

They can be used in a WHERE clause to filter data. They can do the same job as
built-in system functions such as UPPER and ROUND. (*) They can often be used
inside SQL statements. Correct 5. You want to create a function which can be
used in a SQL statement. Which one of the following can be coded within your
function? Mark for Review (1) Points RETURN BOOLEAN One or more IN
parameters (*) An OUT parameter COMMIT; Correct 6. Which of the following is
NOT a legal location for a function call in a SQL statement? Mark for Review (1)
Points FROM clause of a SELECT statement (*) WHERE clause in a DELETE
statement SET clause of an UPDATE statement VALUES clause of an INSERT
statement Correct

LESSON 3 1. You have forgotten the name of the Dictionary view USER_TABLES.
Which of the following statements is the best and quickest way to remind
yourself? Mark for Review (1) Points SELECT * FROM dictionary WHERE
table_name LIKE USER%; Read the online Oracle documentation at
http://technet.oracle.com. SELECT * FROM dict WHERE table_name LIKE 'USER
%TAB%';

(*) SELECT * FROM dictionary WHERE table_name = 'USER_TABLES'; Phone the


database administrator. Correct 2. Which of the following is NOT a benefit of the
Data Dictionary? Mark for Review (1) Points It allows us to remind ourselves of
the names of our tables, in case we have fogotten them.

It allows us to check which system privileges have been granted to us. It will
speed up the execution of SELECT statements in which the WHERE clause
column is not indexed. (*) It allows the PL/SQL compiler to check for object
existence; for example, when creating a procedure which references a table, the
PL/SQL compiler can check that the table exists. Correct 3. Which of the following
will display how many objects of each type are in a user's schema? Mark for
Review (1) Points SELECT COUNT(*) FROM user_objects; SELECT object_type,
COUNT(*) FROM user_objects GROUP BY object_type;

(*) SELECT object_type, COUNT(*) FROM all_objects GROUP BY object_type;


DESCRIBE user_objects GROUP BY object_type; Incorrect. Refer to Section 9
Lesson 3. 4. A user executes the following statement:

CREATE INDEX fn_index ON employees(first_name);

What output will the following statement now display:


SELECT index_name FROM user_indexes WHERE index_name LIKE 'fn%';

Mark for Review (1) Points fn_index FN_INDEX fn_index FN_INDEX No output will
be displayed (*) Correct 5. 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 USER_TABLES ALL_TABLES (*)

DBA_TABLES USER_TAB_COLUMNS None of the above. Correct 6. User MARY


executes the SQL statement:

SELECT COUNT(*) FROM USER_VIEWS;

A value of 15 is returned. Which of the following statements is true?

Mark for Review (1) Points There are 15 views in Mary's schema. (*) Mary has
created views on 15 of her tables. There are 15 views in the database. Other
users have granted Mary SELECT privilege on 15 of their views. Correct 7. Which
of the following statements about the "super-view" DICTIONARY is true? Mark for
Review (1) Points It lists all the dictionary views. It can be thought of as a
"catalog of the master catalog". We can use it like a Web search engine to
remind ourselves of the names of dictionary views. All of the above. (*) None of
the above. Correct 8. 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 is an automatically managed master catalog
of all the objects stored in the database. (*) It contains a backup copy of all the
data in the database. It contains a list of all database tables which are not in any
schema. Correct

LESSON 4

1. Which dictionary view will list all the PL/SQL subprograms in your schema?
Mark for Review (1) Points user_source

user_procedures user_objects (*) user_dependencies user_subprograms Correct


2. proc_a has been created as follows:

CREATE OR REPLACE PROCEDURE proc_a IS v_last_name employees.last_name


%TYPE; BEGIN SELECT last_name INTO v_last_name FROM employees
WHERE employee_id = 999; /* This SELECT will raise an exception because
employee_id 999 does not exist */ DBMS_OUTPUT.PUT_LINE('This SELECT
failed'); END;

proc_b is now created as follows:

CREATE OR REPLACE PROCEDURE proc_b IS BEGIN proc_a;


DBMS_OUTPUT.PUT_LINE('proc_a was invoked'); EXCEPTION WHEN OTHERS
THEN DBMS_OUTPUT.PUT_LINE('An exception occurred'); END;

What will be displayed when proc_b is executed?


Mark for Review (1) Points An exception occurred

(*) This SELECT failed proc_a was invoked An exception occurred This SELECT
failed This SELECT failed proc_a was invoked Nothing will be displayed Correct 3.
The database administrator has granted the DROP ANY PROCEDURE privilege to
user KIM. This allows Kim to remove other users' procedures and functions from
the database. How would Kim now drop function GET_EMP, which is owned by
user MEHMET? Mark for Review (1) Points DROP FUNCTION get_emp FROM
mehmet

DROP FUNCTION mehmet.get_emp (*) DROP PROCEDURE mehmet.get_emp


DROP PROGRAM mehmet.get_emp None of the above Correct 4. Which view
would you query to see the detailed code of a procedure? Mark for Review (1)
Points user_source (*) user_procedures user_objects user_dependencies
user_errors Correct 5. You need to remove procedure BADPROC from your
schema. What is the correct syntax to do this? Mark for Review (1) Points DELETE
PROCEDURE badproc; DROP PROGRAM badproc; ALTER PROCEDURE badproc
DISABLE; DROP PROCEDURE badproc; (*) Incorrect. Refer to Section 9 Lesson 4.
6. Procedure ins_emp accepts an employee_id as an IN parameter and attempts
to insert 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:

CREATE OR REPLACE PROCEDURE call_ins_emp IS BEGIN ins_emp(99); -- this


employee does not exist ins_emp(100); -- this employee already exists
ins_emp(999); -- this employee does not exist EXCEPTION WHEN OTHERS
THEN DBMS_OUTPUT.PUT_LINE('An exception occurred'); END;

When call_ins_emp is executed, which rows will be inserted into the EMPLOYEES
table?

Mark for Review (1) Points 99 only (*) 99 and 999 All three rows will be inserted

999 only No rows will be inserted Correct

LESSON 5 1. USERB creates a function called SEL_PROC (using Definer's Rights)


which includes the statement:

SELECT ... FROM usera.employees ...;

USERC needs to execute UserB's procedure. What privileges are needed for this
to work correctly? (Choose two.)

Mark for Review (1) Points (Choose all correct answers) UserB needs SELECT on
userA.employees (*) UserC needs SELECT on userA.employees UserC needs
EXECUTE on userB.sel_proc (*) UserA needs EXECUTE on userB.sel_proc UserC
needs EXECUTE on Userb Correct 2. User TOM needs to grant both SELECT and
INSERT privileges on both his EMPLOYEES and DEPARTMENTS tables to both DICK
and HARRY. What is the smallest number of GRANT statements needed to do
this? Mark for Review (1) Points 1 2 (*) 3 4 8 Correct 3. User COLLEEN owns an
EMPLOYEES table and wants to allow user AYSE to create indexes on the table.
Which object privilege must Colleen grant to Ayse? Mark for Review (1) Points
SELECT on EMPLOYEES INDEX on EMPLOYEES (*) ALTER on EMPLOYEES CREATE
on EMPLOYEES None of the above Correct

4. 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 GRANT UPDATE
ON departments TO joel; GRANT UPDATE ON departments(location_id) TO joel;
GRANT UPDATE ON departments.location_id TO joel; GRANT UPDATE(location_id)
ON departments TO joel; (*) GRANT UPDATE ON location_id OF departments TO
joel; Correct 5. User SVETLANA creates a view called EMP_VIEW that is based on
a SELECT from her EMPLOYEES table. Svetlana now wants user PHIL to be able to
query the view. What is the smallest set of object privileges that Svetlana must
grant to Phil? Mark for Review (1) Points SELECT on EMP_VIEW and SELECT on
EMPLOYEES SELECT and EXECUTE on EMP_VIEW SELECT on EMP_VIEW (*) SELECT
on EMP_VIEW and REFERENCES on EMPLOYEES Correct 6. User FRED creates a
procedure called DEL_DEPT using Definer's Rights, which deletes a row from
Fred's DEPARTMENTS table. What privilege(s) will user BOB need to be able to
execute Fred's procedure? Mark for Review (1) Points EXECUTE on DEL_DEPT (*)
EXECUTE on DEL_DEPT and DELETE on DEPARTMENTS EXECUTE on DEL_DEPT
and DELETE on FRED.DEPARTMENTS DELETE on FRED.DEPARTMENTS Correct

LESSON 6 1. An autonomous transaction subprogram may be in a the same


package as the calling subprogram or may be in a separate subprogram. True or
False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 9
Lesson 6.

2. When using Invoker's rights, the invoker needs privileges on the database
objects referenced within the subprogram, as well as GRANT privilege on the
procedure. True or False? Mark for Review (1) Points True False (*) Incorrect. Refer
to Section 9 Lesson 6. 3. Procedure GET_EMPS includes a SELECT ... FROM
EMPLOYEES. The procedure was created using Invoker's Rights. Which of the
following statements are true? (Choose three.) Mark for Review (1) Points
(Choose all correct answers) The user who executes the procedure needs
EXECUTE privilege on the procedure. (*) The creator of the procedure needs
SELECT privilege on EMPLOYEES. (*) The user who executes the procedure does
not need any privileges. The user who executes the procedure needs SELECT
privilege on EMPLOYEES. (*) Incorrect. Refer to Section 9 Lesson 6. 4. Which of
the following is the correct syntax to create a procedure using Invoker's Rights?
Mark for Review (1) Points CREATE PROCEDURE myproc IS AUTHID
CURRENT_USER BEGIN ... CREATE PROCEDURE myproc AUTHID CURRENT_USER
IS BEGIN ...

(*) CREATE PROCEDURE AUTHID CURRENT_USER myproc IS BEGIN ... CREATE


PROCEDURE myproc IS BEGIN AUTHID CURRENT_USER ... Correct 5. What will
happen when the following subprogram is compiled?

PROCEDURE at_proc IS PRAGMA AUTONOMOUS_TRANSACTION; dept_id NUMBER


:= 90; BEGIN UPDATE ... INSERT ... END at_proc;
Mark for Review (1) Points The subprogram will fail because it is missing AUTHID
CURRENT_USER before IS. The autonomous transaction subprogram will fail
because it must include COMMIT or ROLLBACK. (*)

The compilation will fail because a semicolon after AUTONOMOUS_TRANSACTION


is not needed. The program will compile successfully. Incorrect. Refer to Section 9
Lesson 6. 6. Users SYS (the DBA), TOM, DICK and HARRY each have an
EMPLOYEES table in their schemas. SYS creates a procedure DICK.SEL_EMP using
Invoker's Rights which contains the following code:

SELECT ... FROM EMPLOYEES ... ;

HARRY now executes the procedure. Which employees table will be queried?

Mark for Review (1) Points SYS.EMPLOYEES DICK.EMPLOYEES HARRY.EMPLOYEES


(*) None of the above Correct 7. 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?

Mark for Review (1) Points The procedure will execute successfully. 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

Anda mungkin juga menyukai