Intrebari Oracle PDF
Intrebari Oracle PDF
4. SQL is a common access language for many types of databases, including Oracle. True
or False? Mark for Review
(1) Points
True (*)
False
Correct
True
False (*)
8. PL/SQL differs from C and Java in which of the following ways? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
9. Procedural constructs give you better control of your SQL statements and their
execution. True or False? Mark for Review
(1) Points
True (*)
False
Correct
10. When multiple SQL statements are combined into PL/SQL blocks, performance
will typically improve. True or False? Mark for Review
(1) Points
True (*)
False
11. Which
sections Mark for Review
of a (1) Points
PL/SQL
block are
optional?
Correct
12. Which of the following tools can NOT be used to develop and test PL/SQL code?
Mark for Review
(1) Points
Oracle iSQL*Plus
Oracle JSQL (*)
Oracle Application Express
Oracle Jdeveloper
13. Which lines of code will correctly display the message "The cat sat on the mat"?
(Choose two.) Mark for Review
(1) Points
14. Every PL/SQL anonymous block must start with the keyword DECLARE. True or
False? Mark for Review
(1) Points
TRUE
FALSE (*)
True
False (*)
3. When multiple SQL statements are combined into PL/SQL blocks, performance
will typically improve. True or False? Mark for Review
(1) Points
True (*)
False
Correct
C++ (*)
Java (*)
MySQL
PL/SQL (*)
SQL
SQL (*)
MySQL (*)
PL/SQL
C++
Java
Declarative
Nondeclarative
procedural (*)
low level
True
False (*)
Correct
11.Errors
are Mark for Review
handled (1) Points
in the
Exception
part of
the
PL/SQL
block.
True or
False?
True (*)
False
Correct
BEGIN (*)
EXCEPTION
DECLARE
END; (*)
Correct
13. In a PL/SQL block, which of the following should not be followed by a semicolon?
Mark for
Review
(1) Points
DECLARE (*)
All SQL statements
All PL/SQL statements
END
Correct
Oracle Cdeveloper
PL/SQL Express
Java*Plus
SQL*Workshop in Application Express (*)
EXCEPTION
DECLARE
END; (*)
DBMS_OUTPUT.PUT_LINE
BEGIN (*)
Section 2 Quiz
(Answer all questions in this section)
1. Which of the following variable declarations does NOT use a number data type?
Mark for
Review
(1) Points
v_count PLS_INTEGER := 0;
v_students LONG; (*)
v_median_age NUMBER(6,2);
v_count BINARY_INTEGER;
2. When declared using %TYPE, a variable will inherit ____ from the column on which it is
based. Mark for
Review
(1) Points
Correct
3. Delimiters are _____ that have special meaning to the Oracle database.
Mark for
Review
(1) Points
Identifiers
Variables
symbols (*)
4. What is a
1. Which Mark for
statement Mark for Review
s about Review (1) Points
lexical
(1) Points
units are
true?
(Choose
two.)
number_of_students_in_the_class
yesterday (*)
v$testresult (*)
#students
yesterday's date
45
29
25 (*)
14
Correct
Correct
True
False (*)
Correct
unit?
A type of variable
A building block of a PL/SQL block (*)
A data type for a column
Exception
Arithmetic (*)
Concatenation (*)
Exponential (*)
6. The implicit
data type Mark for Review
conversion at (1) Points
Point A may
not work
correctly. Why
not?
DECLARE
v_mydate
DATE;
BEGIN
V_MYDATE
:= '29-Feb-
2004'; -- Point
A
END;
Correct
True
False (*)
10. If a variable is defined with the same name in both an inner and outer
block, and referenced in the outer block, it will reference the ___________ Mark for Review
block value of the variable. (1) Points
Neither - can't define a variable with the same name in both blocks
Inner
Outer (*)
8
12
VarB
Nothing, the block will fail with
an error (*)
20
Correct
True
False (*)
DECLARE
fname VARCHAR2(25);
lname VARCHAR2(25) DEFAULT
'fernandez';
BEGIN
…
PLS_INTEGER
Scalar (*)
Composite
LOB
DECLARE
TYPE dept_table_type IS
TABLE OF departments%ROWTYPE
INDEX BY PLS_INTEGER;
v_dept_table dept_table_type;
…
Composite (*)
PLS_INTEGER
Scalar
LOB
Correct
6. Is the
following Mark for Review
variable (1) Points
declaration
correct or
not?
DECLARE
test
NUMBER(5);
Correct. (*)
Not correct.
Correct
7. When a variable is defined using the NOT NULL keywords, the variable must
contain a value. True or False? Mark for Review
(1) Points
True (*)
False
Correct
RECORD (*)
VARCHAR2
CLOB
DATE
Correct
LOBs (*)
VARCHAR2s
Scalar data types
Variables
Correct
10. What good programming practice would make this code easier to follow?
Mark for Review
DECLARE (1) Points
v_myvar VARCHAR2(20);
BEGIN
DECLARE
v_myvar VARCHAR2(15);
BEGIN
...
END;
END;
Labeling the blocks (*)
Developing a case convention for the code
Using a consistent naming convention for variables
Avoid using column names as identifiers
Correct
11. Which of
the Mark for Review
following (1) Points
will help
to make
code
easier to
read?
Naming variables.
Using %Type.
Including comments in the code. (*)
12. Examine the following code. At Line A, we want to assign a value of 22 to the
outer block's variable v_myvar. What code should we write at Line A? Mark for Review
(1) Points
<< outer_block >>
DECLARE
v_myvar NUMBER;
BEGIN
<< inner_block >>
DECLARE
v_myvar NUMBER := 15;
BEGIN
-- Line A
END;
END;
Correct
14. Code is easier to read if you declare one identifier per line. True or False?
Mark for Review
(1) Points
True (*)
False
Correct
15. You need to declare a variable to hold a value which has been read from the
SALARY column of the EMPLOYEES table. Which of the following is an Mark for Review
advantage of declaring the variable as: employees.salary%TYPE ? (1) Points
4. There are three employees in department 90. What will be displayed when the
following code is executed? Mark for Review
(1) Points
DECLARE
v_open CHAR(3) := 'NO';
BEGIN
UPDATE employees
SET job_id = 'ST_CLERK'
WHERE department_id = 90;
IF SQL%FOUND THEN
v_open := 'YES';
END IF;
DBMS_OUTPUT.PUT_LINE(v_open || ' ' || SQL%ROWCOUNT);
END;
YES 1
Nothing will be displayed. The block will fail because you cannot use implicit
cursor attributes directly in a call to DBMS_OUTPUT.PUT_LINE.
YES 3 (*)
NO 3
5. Which of the following SQL DML commands can be used inside a PL/SQL block?
Mark for Review
(1) Points
SELECT salary
FROM employees
INTO v_salary;
SELECT salary
INTO v_salary
FROM employees
WHERE employee_id=100;
(*)
SELECT salary
FROM employees
WHERE employee_id=100
INTO v_salary;
SELECT v_salary
INTO salary
FROM employees
WHERE employee_id=100;
Incorrect. Refer to Section 3 Lesson
2.
7. The following code will return the last name of the employee
whose employee id is equal to 100: True or False? Mark for Review
(1) Points
DECLARE
v_last_name employees.last_name%TYPE;
employee_id employees.employee_id%TYPE := 100;
BEGIN
SELECT last_name INTO v_last_name
FROM employees
WHERE employee_id = employee_id;
END;
True
False (*)
10. When used in a PL/SQL block, which SQL statement must return
exactly one row? Mark for Review
(1) Points
DELETE
SELECT (*)
INSERT
UPDATE
MERGE
Correct
11. The
UPDATE Mark for Review
statement (1) Points
can be
used to
update
more than
one row
at a time.
True or
False?
True (*)
False
Correct
12. To modify an existing row in a table, you can use the ________ statement.
Mark for Review
(1) Points
INSERT
ALTER
UPDATE (*)
MODIFY
(*)
14. You want to modify existing rows in a table. Which of the following are NOT
needed in your SQL statement? Mark for Review
(1) Points
15. When explicitly inserting a row into a table, the VALUES clause must include a
value for every column of the table. True or False? Mark for Review
(1) Points
True
False (*)
SELECT last_name
INTO v_holdit
FROM employees;
SELECT salary
INTO v_holdit
FROM employees
WHERE employee_id=100;
SELECT last_name
INTO v_holdit
FROM employees
WHERE employee_id=100;
(*)
SELECT *
INTO v_holdit
FROM employees;
3. Which rows will be deleted from the EMPLOYEES table when the following code is
executed? Mark for Review
(1) Points
DECLARE
salary employees.salary%TYPE := 12000;
BEGIN
DELETE FROM employees
WHERE salary > salary;
END;
SHOW USER;
SELECT * FROM DUAL;
IF... THEN...;
INSERT INTO...; (*)
No employees earn more than $50000. Which of the following statements are
true? (Choose two).
Correct
6. The
MERGE Mark for Review
statement (1) Points
will
INSERT
or
DELETE
rows in a
target
table
based on
matching
values in
a source
table.
True or
False?
True
False (*)
7. Is it possible to insert more than one row at a time using an INSERT statement
with a VALUES clause? Mark for Review
(1) Points
No, you can only create one row at a time when using the VALUES clause.
(*)
No, there is no such thing as INSERT ... VALUES.
Yes, you can list as many rows as you want, just remember to separate the
rows with commas.
Correct
8. If a DELETE statement does not include a WHERE clause, all rows in the table
are deleted. True or False? Mark for Review
(1) Points
True (*)
False
Correct
The statement fails because you cannot use NULL in the SET clause.
The statement fails because you cannot modify more than one column in a
single UPDATE statement.
All employees in department 50 have their salary changed to 5000 and their
commission percentage set to NULL. (*)
All employees who have a salary of 5000 have their commission percentage
set to NULL.
(*)
INSERT INTO student_table (stud_id, lunch_num, first_name, last_name)
VALUES (143352, 6543, 'Cameron', 'Roberts');
UPDATE
wf_countries
SET
population =
population *
1.1
WHERE
country_id =
229;
Which kind of
cursor is
used for this
statement?
12. There are no employees in Department 77. What will happen when the
following block is executed? Mark for Review
BEGIN (1) Points
DELETE FROM employees
WHERE department_id=77;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT)
END;
Correct
False
True (*)
Null
Error. That attribute does not apply for implicit cursors.
Section 4 Quiz
(Answer all questions in this section)
Calculating and displaying the sum of all integers from 1 to 100 (*)
Assigning a letter grade to a numerical score
Testing if a condition is true, false, or null
Fetching and displaying an employee's last name from the database
Correct
Correct
A nested loop
A WHILE loop
A FOR loop
A basic loop (*)
An infinite loop
When we want to exit from the loop when a Boolean variable becomes FALSE.
When an implicitly declared counter must increase by 1 in each iteration of the
loop. (*)
When the statements inside the loop must execute at least once.
When an EXIT WHEN statement must be coded.
FOR i IN 1 .. 10 BY -1 LOOP
FOR i IN REVERSE 10 .. 1 LOOP
FOR i IN REVERSE 1 .. 10 LOOP (*)
FOR i IN 10 .. 1 LOOP
Correct
2
Null
0 (*)
1
High Paid
The code will fail and return an unhandled exception
error to the host environment (*)
Low Paid
Null
END CASE;
ENDCASE;
END; (*)
ENDIF;
10. In the following code fragment, you want to exit from the
outer loop at Line A if v_number = 6. Which statement would Mark for Review
you write on Line A? (1) Points
FOR loops
All of these. (*)
BASIC loops
WHILE loops
12. …BEGIN
<< Outer_loop >> Mark for Review
LOOP v_counter := v_counter+1; (1) Points
EXIT WHEN v_counter>10;
<< Inner_loop >>
LOOP
...
EXIT Outer_loop WHEN v_total_done = 'YES';
-- Leave both loops
EXIT WHEN v_inner_done = 'YES';
-- Leave inner loop only
...
END LOOP Inner_loop;
...
END LOOP Outer_loop;
END;
In this code it is valid for each loop to have it's own EXIT statement. True or
False?
True (*)
False
Correct
Child
adult (*)
Adultteenagerchild
Teenager
14. We want to execute one of three statements depending on whether the value in
V_VAR is 10, 20, or some other value. What should be coded at Line A? Mark for Review
(1) Points
IF v_var = 10 THEN
statement1;
-- Line A
statement2;
ELSE
statement3;
END IF;
IF v_var = 20 THEN
ELSIF v_var = 20
ELSIF v_var = 20 THEN (*)
ELSE IF v_var = 20 THEN
15. You want to repeat a set of statements 100 times, incrementing a counter each
time. What kind of PL/SQL control structure would you use? Mark for Review
(1) Points
IF...THEN...ELSIF...ELSE
CASE...WHEN...THEN
A loop (*)
IF...THEN...ELSE
Incorrect. Refer to Section 4 Lesson 1.
One only
Two
As many as you need, there is no
limit (*)
None
1
5
6
This is an infinite loop; the loop
will never finish. (*)
6
4 (*)
5
This is an infinite loop; the loop will never
finish.
Incorrect. Refer to
Section 4 Lesson 3.
Correct
10
30 (*)
40
20
Incorrect. Refer to
Section 4 Lesson 2.
Incorrect. Refer to
Section 4 Lesson 2.
41
45 (*)
14
80
Incorrect. Refer to
Section 4 Lesson 5.
EXIT outerloop
EXIT i_loop (*)
EXIT j_loop
EXIT << outerloop>>
12. What statement allows you to exit the inner loop at Point
A in the following block? Mark for Review
(1) Points
DECLARE
v_outer_done CHAR(3) := 'NO';
v_inner_done CHAR(3) := 'NO';
BEGIN
LOOP -- outer loop
...
LOOP -- inner loop
...
v_inner_done := "YES";
... -- Point A
...
END LOOP;
...
EXIT;
...
END LOOP;
END;
TRUE
FALSE (*)
TRUE (*)
FALSE
Correct
Correct
Section 5 Quiz
(Answer all questions in this section)
v_emp_dept_rec emp_dept_type;
two
one
four (*)
three
2. You can store a whole record in a single variable using %ROWTYPE or by creating your
own record structure as a type and then declaring a variable of that type. Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
4. The following code declares a PL/SQL record with the same structure as a row of the
departments table. True or False? Mark for Review
(1) Points
DECLARE
v_dept_rec departments%ROWTYPE;
...
True (*)
False
Correct
v_dept_info_rec dept_info_type;
v_emp_dept_rec emp_dept_type;
two (*)
Four
One
Three
Correct
6. Which of
these Mark for Review
PL/SQL (1) Points
data
structures
can NOT
store a
collection?
True (*)
False
Correct
Correct
9. To declare an INDEX BY table, we must first declare a type and then declare a
collection variable of that type. True or False? Mark for Review
(1) Points
True (*)
False
Correct
10. Which of the following successfully declares an INDEX BY table of records which
could be used to store copies of complete rows from the departments table? Mark for Review
(1) Points
DECLARE
TYPE t_depttab IS TABLE OF departments%TYPE
INDEX BY BINARY_INTEGER;
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEXED BY NUMBER;
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
(*)
DECLARE
TYPE t_depttab IS INDEX BY TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
11. An
INDEX Mark for Review
BY (1) Points
TABLE
primary
key
cannot
be
negative.
True
False (*)
12. What is the largest number of elements (i.e., records) that an INDEX BY table of
records can contain? Mark for Review
(1) Points
32767
100
None of these.
Many millions of records because a BINARY_INTEGER or PLS_INTEGER can
have a very large value (*)
4096
13. Which of the following methods can be used to reference elements of an INDEX
BY table? (Choose three.) Mark for Review
(1) Points
DROP
COUNT (*)
EXISTS (*)
FIRST (*)
PREVIOUS
Incorrect. Refer to Section 5 Lesson 2.
14. Which of these PL/SQL data structures could store a complete copy of the
employees table, i.e., 20 complete table rows? Mark for Review
(1) Points
A record
An INDEX BY table of records (*)
An INDEX BY table
An explicit cursor based on SELECT * FROM employees;
Correct
v_emp_dept_rec emp_dept_type;
Correct
DECLARE
v_dept_rec departments%ROWTYPE;
...
True (*)
False
Correct
(*)
TYPE person_type IS RECORD
(l_name VARCHAR2(20),
gender CHAR(1));
person_rec TYPE person_type;
TYPE person_type IS (l_name
VARCHAR2(20),
gender CHAR(1));
person_rec TYPE person_type;
TYPE person_type IS (l_name
VARCHAR2(20),
gender CHAR(1));
person_rec person_type;
Correct
True (*)
False
Correct
6. Which of
these Mark for Review
PL/SQL (1) Points
data
structures
can NOT
store a
collection?
7. Which of these PL/SQL data structures could store a complete copy of the
employees table, i.e., 20 complete table rows? Mark for Review
(1) Points
Correct
EXISTS (*)
DROP
PREVIOUS
FIRST (*)
COUNT (*)
9. To declare an INDEX BY table, we must first declare a type and then declare a
collection variable of that type. True or False? Mark for Review
(1) Points
True (*)
False
Correct
10. Which of the following successfully declares an INDEX BY table of records which
could be used to store copies of complete rows from the departments table? Mark for Review
(1) Points
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEXED BY NUMBER;
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
(*)
DECLARE
TYPE t_depttab IS INDEX BY TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
DECLARE
TYPE t_depttab IS TABLE OF departments%TYPE
INDEX BY BINARY_INTEGER;
Incorrect. Refer to Section 5 Lesson 2.
11. An
INDEX Mark for Review
BY (1) Points
TABLE
primary
key
cannot
be
negative.
True
False (*)
%ROWTYPE
a user-defined record
Either one. (*)
13. What is the largest number of elements (i.e., records) that an INDEX BY table of
records can contain? Mark for Review
(1) Points
None of these.
4096
Many millions of records because a BINARY_INTEGER or PLS_INTEGER can
have a very large value (*)
32767
100
Correct
True (*)
False
Correct
Section 6 Quiz
(Answer all questions in this section)
To display the salary of an employee, what code should you write at Point A?
emp_cursor.salary
emp_record.salary (*)
employees.salary
emp_record.employees.salary
TO_CHAR(salary)
5. You want to fetch rows from the EMPLOYEES table. You want to lock the fetched rows
to prevent other users from updating them. You declare the following cursor: CURSOR Mark for Review
emp_curs IS (1) Points
SELECT employee_id, last_name, salary
FROM employees
-- Line A -- ; What should you code at Line A?
FOR LOCK
FOR UPDATE OF employees
FOR UPDATE (*)
FOR UPDATE (employees)
v_emp_rec
v_emp_rec.last_name (*)
v_emp_rec(last_name)
None of these.
last_name
Correct
p_param := 'ABC';
OPEN c_curs(p_param);
OPEN c_curs(p_param = "ABC");
OPEN c_curs USING ("ABC");
OPEN c_curs('ABC'); (*)
v_salary
employees.salary%TYPE;
BEGIN
...
Which of the following
statements successfully
opens the cursor and fetches
the first row of the active
set?
OPEN emp_curs;
FETCH emp_curs;
OPEN emp_curs;
FETCH emp_curs INTO v_salary, v_last_name;
OPEN emp_curs;
FETCH emp_curs INTO v_last_name, v_salary;
(*)
OPEN emp_curs;
FETCH FIRST emp_curs INTO v_last_name, v_salary;
12. For which type of SQL statement must you use an explicit
cursor? Mark for
Review
(1) Points
Correct
1. User TOM
has Mark for Review
locked a (1) Points
row in the
WORKERS
table.
Now, user
DICK
wants to
open the
following
cursor:
CURSOR c
IS
SELECT
* FROM
workers
FOR
UPDATE
NOWAIT;
What will
happen
when
DICK
opens the
cursor
and tries
to fetch
rows?
Which employee row or rows will be updated when this block is executed?
Correct
3. You have declared a cursor as SELECT .... FOR UPDATE; You have OPENed the
cursor and locked the FETCHed rows. When are these row locks released? Mark for Review
(1) Points
5. Assume your schema contains 25 tables. How many explicit cursors can you
declare and use within a single PL/SQL block? Mark for Review
(1) Points
Correct
6. Which of
these Mark for Review
constructs (1) Points
can be
used to
fetch
multiple
rows from
a cursor's
active
set?
A CASE statement
An IF .... ELSE statement
A basic loop which includes OPEN, FETCH, and CLOSE statements
A basic loop which includes FETCH and EXIT WHEN statements (*)
A,C,D,B
C,D,A,B
C,A,B,D
C,A,D,B (*)
9. Which of the following best describes the difference between implicit and explicit
cursors? Mark for Review
(1) Points
Implicit cursor are named by the PL/SQL programmer, while explicit cursors
are always named SQL.
Implicit cursors are used for SELECT statements, while explicit cursors are
used for DML statements.
Implicit cursors are defined automatically by Oracle, while explicit cursors
must be declared by the PL/SQL programmer. (*)
Implicit cursors store rows on disk, while explicit cursors store rows in
memory.
True
False (*)
You want to open the cursor, passing value 50 to the parameter. Which of the
following are correct at Point A?
100 / 2
All of these. (*)
v_deptid
50
Incorrect. Refer to Section 6 Lesson 4.
13. Examine the following declaration of a cursor with a parameter. What should
be coded at Point A? Mark for Review
(1) Points
DECLARE
CURSOR emp_curs(-- Point A --) IS
SELECT * FROM employees
WHERE job_id = p_job_id;
Correct
Section 7 Quiz
(Answer all questions in this section)
1. Examine the followiing code. Which exception handlers would successfully trap the
exception which will be raised when this code is executed? (Choose two.) Mark for Review
(1) Points
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;
WHEN INVALID_FETCH
WHEN OTHERS (*)
WHEN CURSOR_NOT_OPEN
WHEN INVALID_CURSOR (*)
WHEN NO_DATA_FOUND
2. Examine the following code. What message or messages will be displayed when this
code is executed? Mark for Review
(1) Points
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;
An error occurred
Attempt to divide by zero (*)
No message will be displayed
Attempt to divide by zero No rows were found
No rows were found
3. What is the correct syntax to associate an exception named EXCEPNAME with the non-
predefined Oracle Server error ORA-02292? Mark for Review
(1) Points
4. An attempt to insert a null value into a NOT NULL table column raises an ORA-01400
exception. How can you code an exception handler to trap this exception? Mark for Review
(1) Points
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sal_excep,02290);
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
PRAGMA EXCEPTION_INIT(e_sal_excep,-02290);
e_sal_excep EXCEPTION;
DECLARE
e_sal_excep EXCEPTION;
PRAGMA EXCEPTION_INIT(-02290,e_sal_excep);
6. Which of
the Mark for Review
following (1) Points
EXCEPTION
sections is
constructed
correctly?
(Choose
three.)
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
END;
(*)
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
WHEN OTHERS THEN statement_3;
END;
EXCEPTION
WHEN TOO_MANY_ROWS THEN statement_1;
END;
(*)
EXCEPTION
WHEN OTHERS THEN statement_1;
END;
(*)
EXCEPTION
WHEN OTHERS THEN statement_1;
WHEN NO_DATA_FOUND THEN statement_2;
END;
EXCEPTION
WHEN NO_DATA_FOUND THEN statement_1;
WHEN OTHERS THEN statement_2;
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_2;
WHEN NO_DATA_FOUND THEN statement_1;
END;
TRUE (*)
FALSE
Correct
10. 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
11. Non-predefined
Oracle Server Mark for Review
errors (associated (1) Points
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 (*)
B
A and C
C
B and C (*)
A and B
True
False (*)
1. Exceptions
declared Mark for Review
in a block (1) Points
are
considered
local to
that block,
and global
to all its
sub-
blocks.
True or
False?
True (*)
False
Correct
True (*)
False
Correct
True (*)
False
Correct
4. How can you retrieve the error code and error message of any Oracle Server
exception? Mark for Review
(1) Points
By using RAISE_APPLICATION_ERROR
By using the functions SQLCODE and SQLERRM (*)
By using the functions SQLCODE and SQLERR
By defining an EXCEPTION variable and using PRAGMA EXCEPTION_INIT
6. Which kinds of
exceptions are Mark for Review
raised (1) Points
implicitly (i.e.,
automatically)?
(Choose two.)
All errors
Predefined Oracle Server errors such as NO_DATA_FOUND (*)
User-defined errors
Non-predefined Oracle Server errors such as ORA-01400 (*)
NO_DATA_FOUND
TOO_MANY_ROWS
ZERO_DIVIDE
DUP_VAL_ON_INDEX
e_sal_too_high EXCEPTION; (*)
Message 1
Message 3
Message 4
The code will not execute because it contains at least one syntax error.
Message 1
Message 2
Message 3
Message 4
The code will execute but will return an unhandled exception to the
calling environment.
(*)
Message 1
Message 3
10. You want to display your own error message to the user. What is the
correct syntax to do this? Mark for Review
(1) Points
By PRAGMA EXCEPTION_INIT
By RAISE exception_name; (*)
By DECLARE e_my_excep EXCEPTION;
None of these. They are raised automatically by the Oracle server.
Any other kind of exception that can occur within the block
An attempt is made to divide by zero
A SELECT statement returns no rows
All of these. (*)
None of these.
TRUE (*)
FALSE
Correct
14. Examine the following code. Why does this exception handler not follow good
practice guidelines? Mark for Review
(1) Points
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;
15. While a PL/SQL block is executing, more than one exception can occur at the
same time. True or False? Mark for Review
(1) Points
TRUE
FALSE (*)
Section 8 Quiz
(Answer all questions in this section)
1. PL/SQL subprograms, unlike anonymous blocks, are compiled each time they are
executed. True or False? Mark for Review
(1) Points
True
False (*)
Hosted subprogram
Limited subprogram
Local subprogram (*)
3. Which of the following are benefits of using PL/SQL subprograms rather than
anonymous blocks? (Choose three.) Mark for Review
(1) Points
4. One PL/SQL subprogram can be invoked from within many applications. True or False?
Mark for Review
(1) Points
TRUE (*)
FALSE
Correct
One time
Two times
Four times
Zero times (*)
Eight times
The procedure is
invoked by:
DECLARE
v_param NUMBER :=
20;
BEGIN
smallproc(v_param);
END;
True
False (*)
Correct
myproc(v_left, v_right);
All of the above (*)
myproc(p_left, p_right);
myproc(v_left, 30);
10. Parameters are a special form of a variable, whose input values are
initialized by the calling environment when the subprogram is called, Mark for Review
and whose output values are returned to the calling environment (1) Points
when the subprogram returns control to the caller.
True (*)
False
Correct
CREATE OR REPLACE
PROCEDURE
format_phone
(p_phone_no IN OUT
VARCHAR2) IS
BEGIN
p_phone_no :=
SUBSTR(p_phone_no,1,3)
||
'.' ||
SUBSTR(p_phone_no,4,3)
||
'.' ||
SUBSTR(p_phone_no,7);
END format_phone;
Positionally
A combination of named and defaulted
A combination of positionally and named
Named (*)
Defaulted
Correct
None of these.
Named
Positional
A combination of positional and named (*)
CONSTANT
NUMBER
OUT
IN (*)
VARIABLE
Positional (*)
A combination of named and defaulted
Defaulted
A combination of positionally and named
Named
Correct
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;
Correct
All of these.
An action (*)
A return of values
None of these.
A SELECT statement
True
False (*)
BEGIN
add_dept;
END;
True (*)
False
Correct
11. Which of
the Mark for Review
following (1) Points
can NOT
be used as
the
datatype of
a
procedure
parameter?
An expression
A literal value
None of these.
All of these. (*)
The name of a variable
13. Which of the following statements about actual parameters is NOT true?
Mark for Review
(1) Points
14. You have created procedure MYPROC with a single parameter PARM1
NUMBER. Now you want to add a second parameter to the procedure. Which Mark for Review
of the following will change the procedure successfully? (1) Points
ALTER PROCEDURE myproc ADD (parm2 NUMBER);
CREATE OR REPLACE PROCEDURE myproc
(parm1 NUMBER, parm2 NUMBER);
(You do not need to repeat the detailed code of the procedure, only the
header)
The procedure cannot be modified. Once a procedure has been created,
the number of parameters cannot be changed.
CREATE OR REPLACE PROCEDURE myproc
(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ... (*)
REPLACE PROCEDURE myproc
(parm1 NUMBER, parm2 NUMBER)
IS
BEGIN ...
15. Which of the following best describes the difference between a parameter and
an argument? Mark for Review
(1) Points
Correct
Section 9 Quiz
(Answer all questions in this section)
1. A stored function:
Mark for Review
(1) Points
Correct
2. Which of the following is a difference between a procedure and a function?
Mark for Review
(1) Points
A procedure can have default values for parameters, while a function cannot.
A function must return a value; a procedure may or may not. (*)
A function cannot be used within a SQL statement; a procedure can be used
within SQL.
Functions cannot be nested; procedures can be nested to at least 8 levels.
An explicit cursor can be declared in a procedure, but not in a function.
3. 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 Mark for Review
errors? (1) Points
USER_COMPILES
USER_SOURCE
USER_DEPENDENCIES
USER_OBJECTS
USER_ERRORS (*)
USERC needs to execute UserB's procedure. What privileges are needed for this to work
correctly? (Choose two.)
True (*)
False
Correct
SELECT
employee_id,
tax(p_value
=> salary)
FROM
employees;
The data type for the tax variable does not match the data type for
salary.
The statement will execute and not fail.
User-defined functions are not allowed in the SELECT clause.
Name notation is not allowed. (*)
True
False (*)
8. A benefit of user-defined functions is that the function can accept any SQL or
PL/SQL data type. True or False? Mark for Review
(1) Points
True
False (*)
USER_TABLES
ALL_TABLES (*)
DBA_TABLES
DICTIONARY
FRED_TABLES
10. You want to see the names of all the columns in a table in your schema. You
want to query the Dictionary instead of using the DESCRIBE command. Which Mark for Review
Dictionary view should you query? (1) Points
USER_TABLES
USER_OBJECTS
USER_TAB_COLS (*)
USER_COLUMNS
11. Which of
the Mark for Review
following (1) Points
will tell
you how
many
functions
you
own?
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? (Choose two) Mark for Review
(1) Points
Query USER_FUNCTIONS
Query USER_SOURCE (*)
Query USER_PARAMETERS
DESCRIBE my_func; (*)
SHOW PARAMETER my_func;
13. Which dictionary view will list all the PL/SQL subprograms in your schema?
Mark for Review
(1) Points
user_subprograms
user_dependencies
user_objects (*)
user_source
user_procedures
The subprogram will fail because the PRAGMA statement must be before
IS.
The program will compile successfully.
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. (*)
user_errors
user_procedures
user_source (*)
user_objects
user_dependencies
Employee_id 9999 does not exist. What happens when PARENT is executed?
CHILD1 ends abruptly, and then PARENT also ends abruptly with an
unhandled exception.
PARENT handles the exception, and then CHILD1 resumes execution.
CHILD1 handles the exception successfully and ends. PARENT continues to
execute and invokes CHILD2. (*)
PARENT fails to compile because you cannot have the same exception
handler in two separate subprograms.
CHILD1 ends abruptly, and PARENT handles the exception successfully and
ends. CHILD2 does not execute.
3. The function avg_ann_sal returns the average annual salary for a particular
department. The example below is a valid use of this function. True or False? Mark for Review
(1) Points
SELECT first_name, last_name
FROM employees
WHERE avg_ann_sal(20) > 15000;
True (*)
False
Correct
Correct
6. User REYHAN
creates the Mark for Review
following (1) Points
procedure:
CREATE
PROCEDURE
proc1
AUTHID
CURRENT_USER
IS
v_count
NUMBER;
BEGIN
SELECT
COUNT(*) INTO
v_count
FROM
tom.employees;
END;
7. How do you specify that you want a procedure MYPROCA to use Invoker's
Rights? Mark for Review
(1) Points
(*)
Invoker's Rights are the default, therefore no extra code is needed.
CREATE OR REPLACE PROCEDURE myproca
AUTHID OWNER IS...
v_job_id := get_job(100);
get_job(100,v_job_id); (*)
IF get_job(100) = 'IT_PROG' THEN ...
DBMS_OUTPUT.PUT_LINE(get_job(100));
9. Function MYFUNC1 has been created, but has failed to compile because it
contains syntax errors. We now try to create procedure MYPROC1 which Mark for Review
invokes this function. Which of the following statements is true? (1) Points
Correct
10. You try to create a function named MYFUNC. The function does not
compile correctly because there are errors in your code. Which Dictionary Mark for Review
view can you query to see the errors? (1) Points
USER_COMPILES
USER_DEPENDENCIES
USER_SOURCE
USER_OBJECTS
USER_ERRORS (*)
Incorrect. Refer to Section 9 Lesson 1.
11. Which
object Mark for Review
privilege (1) Points
can be
granted
on a
single
column
of a
table?
DELETE
CREATE
DROP
UPDATE (*)
SELECT
12. When a database object is first created, only its owner (creator) and the
Database Administrator are privileged to use it. True or False? Mark for Review
(1) Points
True (*)
False
Correct
13. JOHN and FRED are database users. JOHN grants SELECT privilege to FRED on
three of his (JOHN's) tables. Which Dictionary view should FRED query to see the Mark for Review
names of JOHN's three tables? (1) Points
DBA_TABLES
ALL_TABLES (*)
FRED_TABLES
DICTIONARY
USER_TABLES
14. You want to see the names of all the columns in a table in your schema. You
want to query the Dictionary instead of using the DESCRIBE command. Which Mark for Review
Dictionary view should you query? (1) Points
USER_TAB_COLS (*)
USER_COLUMNS
USER_TABLES
USER_OBJECTS
Correct
SELECT index_name
FROM user_indexes
WHERE index_name LIKE 'fn%';
FN_INDEX
fn_index FN_INDEX
No output will be displayed (*)
fn_index
Section 10 Quiz
(Answer all questions in this section)
Correct
Which of the following are correct syntax for invoking the package subprograms?
(Choose two.)
DECLARE
v_deptname VARCHAR2(20);
BEGIN
v_deptname := get_dept(50);
END;
BEGIN
dept_pack.ins_dept(20);
END;
(*)
BEGIN
dept_pack.get_dept(20);
END;
CREATE PROCEDURE dept_proc IS
v_deptname VARCHAR2(20);
BEGIN
v_deptname := dept_pack.get_dept(40);
END;
(*)
BEGIN
dept_pack(30);
END;
Correct
True (*)
False
Correct
6. When
using a Mark for Review
package (1) Points
function in
DML
statements,
which rules
must you
follow?
(Choose
three)
Can read or modify the table being changed by that DML statement
Changes to a package variable could have an impact on another stored
function (*)
Must not end the current transaction (*)
Cannot execute a DML statement or modify the database (*)
True
False (*)
1 and 3 (*)
2 and 3
1 and 4
3 and 4
1 and 2
Correct
9. Which of the following are not allowed in a bodiless package? (Choose three)
Mark for Review
(1) Points
Subprograms (*)
Private variables (*)
User-defined exceptions
Global variables
DML statements (*)
True (*)
False
Correct
SELECT
COUNT(*)
FROM
ALL_OBJECTS
WHERE
object_type
LIKE 'PACK%'
AND owner
<> USER;
3
6 (*)
7
14
0
12. Which of the following will display the detailed code of the subprograms in
package DEPTPACK in your schema ? Mark for Review
(1) Points
(*)
SELECT text FROM USER_SOURCE
WHERE name = 'DEPTPACK'
AND type = 'PACKAGE'
ORDER BY line;
SELECT text FROM USER_SOURCE
WHERE object_name = 'DEPTPACK'
AND object_type = 'PACKAGE BODY'
ORDER BY line;
Incorrect. Refer to Section 10 Lesson 2.
Correct
14. When one component of a package is called, all the package's components
are loaded into memory. True or False? Mark for Review
(1) Points
True (*)
False
Correct
True
False (*)
1. Package
Specification Mark for Review
DEPT_PACK was (1) Points
created by the
following code:
CREATE OR
REPLACE PACKAGE
dept_pack IS
PROCEDURE
ins_dept(p_deptno
IN NUMBER);
FUNCTION
get_dept(p_deptno
IN NUMBER)
RETURN
VARCHAR2;
END dept_pack;
Which of the
following are
correct syntax for
invoking the
package
subprograms?
(Choose two.)
BEGIN
dept_pack.get_dept(20);
END;
DECLARE
v_deptname VARCHAR2(20);
BEGIN
v_deptname := get_dept(50);
END;
CREATE PROCEDURE dept_proc IS
v_deptname VARCHAR2(20);
BEGIN
v_deptname := dept_pack.get_dept(40);
END;
(*)
BEGIN
dept_pack.ins_dept(20);
END;
(*)
BEGIN
dept_pack(30);
END;
True (*)
False
Correct
3. What is wrong with the following syntax for creating a package
specification? Mark for Review
(1) Points
CREATE OR REPLACE mypack IS
g_constant1 NUMBER(6) := 100;
PROCEDURE proc1 (p_param1 IN VARCHAR2);
PROCEDURE proc2;
END mypack;
(*)
Nothing is wrong, this code contains no errors.
A package must contain at least one function.
Body (*)
Neither the body nor the specification
Specification
Both the body and the specification
Correct
5. Which of the following are good reasons for creating and using
Packages? Mark for Review
(1) Points
A. Related procedures, functions, and variables can be grouped
together as a single unit
B. We can recompile the package body without having to
recompile the specification
C. We can create packages without needing any system privileges
D. The detailed package body code is invisible to the calling
environment.
A, B, and C
A, B, C, and D
A, B, and D (*)
A and B
A and C
6. Your schema
contains a Mark for Review
package (1) Points
called
EMP_PKG.
You want to
remove the
package
body but not
the
specification.
The correct
syntax to do
this is:
DROP BODY
emp_pkg;
True or
False?
True
False (*)
The package will not compile because you cannot declare a cursor in the
specification.
(*)
TAXPROC can open the cursor.
The procedure can be invoked by:
BEGIN
taxpack.taxproc;
END;
TAXPROC can invoke TAXFUNC if TAXPROC is coded before TAXFUNC.
TAXPROC is public and TAXFUNC is private.
Correct
True
False (*)
True
False (*)
True
False (*)
11. The
package Mark for Review
name (1) Points
must be
included
when
calling a
package
function
from a
SELECT
statement
executed
outside
the
package.
True or
False?
True (*)
False
Correct
(*)
CREATE OR REPLACE PACKAGE BODY forward_pack IS
PROCEDURE proc2;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Any message');
END;
END forward_pack;
CREATE OR REPLACE PACKAGE BODY forward_pack IS
PROCEDURE proc2;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
BEGIN
proc1;
END;
END forward_pack;
CREATE OR REPLACE PACKAGE BODY forward_pack IS
PROCEDURE proc1;
PROCEDURE proc1 IS
BEGIN
proc2;
END;
PROCEDURE proc2 IS
proc1;
END;
END forward_pack;
(*)
13. Functions called from a SQL query or DML statement must not end the current
transaction, or create or roll back to a savepoint. True or False? Mark for Review
(1) Points
True (*)
False
Correct
14. Which two of these functions could not be in the same package?
Mark for Review
1. FUNCTION get_emp (p1 DATE) RETURN VARCHAR2; (1) Points
2. FUNCTION get_emp (p1 DATE, p2 NUMBER) RETURN VARCHAR2;
3. FUNCTION get_emp (p1 DATE, p2 NUMBER) RETURN NUMBER;
4. FUNCTION get_emp (p1 NUMBER, p2 DATE) RETURN VARCHAR2;
2 and 3 (*)
1 and 4
2 and 4
1 and 2
3 and 4
Correct
15. A public function in a package is invoked from within a SQL statement. The
function's code can include a COMMIT statement. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 10 Lesson 3.
Section 11 Quiz
(Answer all questions in this section)
1. Which DBMS_OUTPUT package subprogram places text into the buffer at Line 1?
(Choose one) Mark for Review
(1) Points
IF v_bool1 AND NOT v_bool2 AND v_number < 25 THEN
--Line 1
ELSE
...
END IF;
DBMS_OUTPUT.NEW_LINE;
2. Which of the following procedures is not valid for the UTL_MAIL package
Mark for Review
(1) Points
SEND_ATTACH_RAW
SEND_ATTACH_VARCHAR2
SEND
SEND_ATTACH_BOOLEAN (*)
All are valid.
ZERO_DIVIDE
VALUE_ERROR (*)
NO_DATA_FOUND (*)
TOO_MANY_ROWS
4. The DBMS_OUTPUT package is useful for which of the following activities? (Choose
two) Mark for Review
(1) Points
True (*)
False
Correct
6. The
UTL_FILE Mark for Review
package (1) Points
can be
used to
create
binary
files such
as JPEGs
as well
as text
files.
True or
False?
True
False (*)
True (*)
False
Correct
INVALID_PATH (*)
WRITE_ERROR (*)
INVALID_OPERATION (*)
NO_DATA_FOUND
ZERO_DIVIDE
Correct
True (*)
False
Correct
10. Using the FOPEN function, you can do which actions with the UTL_FILE package?
(Choose 2) Mark for Review
(1) Points
11. When a
user Mark for Review
session (1) Points
changes
the value of
a package
variable,
the new
value can
immediately
be seen by
other
sessions.
True or
False?
True
False (*)
12. A cursor's state is defined only by whether it is open or closed and, if open,
how many rows it holds. True or False? Mark for Review
(1) Points
True
False (*)
13. A package's state is initialized when the package is first loaded. True or
False? Mark for Review
(1) Points
True (*)
False
Correct
14. In the following example, which statement best fits in Line 1? (Choose 1)
Mark for Review
DECLARE (1) Points
v_more_rows_exist BOOLEAN := TRUE;
BEGIN
-- Line 1
LOOP
v_more_rows_exist := curs_pkg.fetch_n_rows(3);
DBMS_OUTPUT.PUT_LINE('-------');
EXIT WHEN NOT v_more_rows_exist;
END LOOP;
curs_pkg.close_curs;
END;
curs_pkg.close_curs;
curs_pkg.emp_curs%ISOPEN;
curs_pkg.open_curs; (*)
EXIT WHEN curs_pkg.emp_curs%NOTFOUND;
User HAZEL now connects to the database. Both users immediately execute:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
1. Which of
the Mark for Review
following (1) Points
procedures
is not valid
for the
UTL_MAIL
package
SEND_ATTACH_RAW
SEND_ATTACH_BOOLEAN (*)
SEND
All are valid.
SEND_ATTACH_VARCHAR2
2. Using the FOPEN function, you can do which actions with the UTL_FILE
package? (Choose 2) Mark for Review
(1) Points
It is used to read and write text files stored outside the database. (*)
It is used to append to a file until processing is complete. (*)
It is used to manipulate large object data type items in columns.
It is used to find out how much free space is left on an operating system
disk.
Correct
3. Which of the following best describes the purpose of the UTL_FILE package?
Mark for Review
(1) Points
It is used to load binary files such as employees' photos into the database.
It is used to query CHAR and VARCHAR2 columns in tables.
It is used to read and write text files stored outside the database. (*)
It is used to find out how much free space is left on an operating system
disk.
VALUE_ERROR (*)
ZERO_DIVIDE
NO_DATA_FOUND (*)
TOO_MANY_ROWS
Incorrect. Refer to Section 11 Lesson 2.
True (*)
False
Correct
6. The
UTL_FILE Mark for Review
package (1) Points
contains
several
exceptions
exclusively
used in
this
package.
Which are
they?
(Choose
3)
ZERO_DIVIDE
WRITE_ERROR (*)
INVALID_OPERATION (*)
NO_DATA_FOUND
INVALID_PATH (*)
Correct
Correct
I do like to be
I do like to be beside the seaside
I do like to be
beside the seaside
I do liketo be
(*)
I do like
to be
beside the seaside
True (*)
False
Correct
11. A
package's Mark for Review
state is (1) Points
initialized
when the
package
is first
loaded.
True or
False?
True (*)
False
Correct
12. A cursor is declared in a package specification. User SIOBHAN opens the cursor
and fetches the first three rows from the cursor's active set, but does not close Mark for Review
the cursor. (1) Points
User FRED now connects to the database. FRED can immediately fetch the next
three rows without opening the cursor. True or False?
True
False (*)
13. Users A and B call the same procedure in a package to initialize a global
variable my_pkg.g_var. What will be the value of my_pkg.g_var for User A at Mark for Review
Point A? (1) Points
User A: my_pkg.g_var is 10
User B: my_pkg.g_var is 10
User A: my_pkg.g_var is 50
User B: my_pkg.g_var is 25
Point A
50 (*)
25
10
Correct
14. When a user session changes the value of a package variable, the new value
can immediately be seen by other sessions. True or False? Mark for Review
(1) Points
True
False (*)
15. Package CURSPACK declares a global cursor in the package specification. The
package contains three public procedures: OPENPROC opens the cursor; Mark for Review
FETCHPROC fetches 5 rows from the cursor's active set; CLOSEPROC closes the (1) Points
cursor.
What will happen when a user session executes the following commands in the
order shown?
curspack.openproc; -- line 1
curspack.fetchproc; -- line 2
curspack.fetchproc; -- line 3
curspack.openproc; -- line 4
curspack.fetchproc; -- line 5
curspack.closeproc; -- line 6
Section 12 Quiz
(Answer all questions in this section)
Provides the ability to execute SQL statements whose structure is unknown until
execution time. (*)
Provides the ability to handle mutating rows when executing a statement involving
the same table.
Enables session-control statements to be written and executed from PL/SQL. (*)
Allows fetch of data for DML statements.
2. The following procedure adds a column of datatype DATE to the EMPLOYEES table. The
name of the new column is passed to the procedure as a parameter. Mark for Review
(1) Points
CREATE OR REPLACE PROCEDURE addcol
(p_col_name IN VARCHAR2) IS
v_first_string VARCHAR2(100) := 'ALTER TABLE EMPLOYEES ADD (';
v_second_string VARCHAR2(6) := ' DATE)';
BEGIN
... Line A
END;
Which of the following will work correctly when coded at line A? (Choose two.)
(*)
EXECUTE v_first_string || p_col_name || v_second_string;
EXECUTE IMMEDIATE 'v_first_string' || p_col_name || 'v_second_string';
v_first_string := v_first_string || p_col_name;
EXECUTE IMMEDIATE v_first_string || v_second_string;
(*)
v_first_string || p_col_name || v_second_string;
True (*)
False
Correct
4. The DBMS_SQL package is easier to use than EXECUTE IMMEDIATE. True or False?
Mark for Review
(1) Points
True
False (*)
5. When SQL statements are included within a procedure, the statements are parsed
when the procedure is compiled. True or False? Mark for Review
(1) Points
True (*)
False
Correct
6. Which of
the Mark for Review
following (1) Points
SQL
statements
can be
included in
a PL/SQL
block only
by using
Dynamic
SQL?
(Choose
two.)
True (*)
False
Correct
Position A
Position B (*)
Position C
10. You want to take make a copy of all the cities in the world listed in the cities
table, which contains millions of rows. The following procedure accomplishes Mark for Review
this efficiently. True or False? (1) Points
True (*)
False
Correct
DECLARE
TYPE EmpRec IS RECORD
(last_name
employees.last_name%TYPE,
salary
employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees
SET salary = salary * 1.1
WHERE employee_id =
emp_id;
RETURNING last_name,
salary INTO emp_info;
dbms_output.put_line('Just
gave a raise to ' ||
emp_info.last_name ||
', who now makes ' ||
emp_info.salary);
END;
True (*)
False
Correct
Position A
Position B (*)
Position C
Position D
True (*)
False
Correct
True (*)
False
Correct
1. A SQL
statement Mark for Review
can pass (1) Points
through
several
stages.
Which of
the
following
is NOT
one of
these
stages?
BIND
EXECUTE
FETCH
PARSE
RETURN (*)
2. Only one call to DBMS_SQL is needed in order to drop a table. True or False?
Mark for Review
(1) Points
True
False (*)
3. You want to create a function which drops a table. You write the following code:
Mark for Review
CREATE OR REPLACE FUNCTION droptab (1) Points
(p_tab_name IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
DROP TABLE p_tab_name;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
True (*)
False
Correct
6. The
easiest Mark for Review
way to (1) Points
include
DDL
statements
in a
PL/SQL
block is to
use the
DBMS_SQL
package.
True or
False?
True
False (*)
Parse
Bind
Execute
Fetch
(*)
Execute
Parse
Fetch
Bind
Bind
Parse
Execute
Fetch
Parse
Fetch
Bind
Execute
Correct
True (*)
False
Correct
9. In the following example, where do you place the phrase BULK COLLECT?
Mark for Review
DECLARE (1) Points
TYPE NameList IS TABLE OF emp.ename%TYPE;
names NameList;
CURSOR c1 IS SELECT ename -- Position A
FROM emp WHERE job = 'CLERK';
BEGIN
OPEN c1;
FETCH c1 -- Position B
INTO -- Position C
names;
...
CLOSE c1;
END;
Position A
Position B (*)
Position C
10. Deterministic means the function will always return the same output return
value for any given set of input argument values. True or False? Mark for Review
(1) Points
True (*)
False
Correct
DECLARE
TYPE EmpRec IS RECORD
(last_name
employees.last_name%TYPE,
salary
employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees
SET salary = salary * 1.1
WHERE employee_id =
emp_id
-- Position A
dbms_output.put_line('Just
gave a raise to ' ||
emp_info.last_name || ', who
now makes ' ||
emp_info.salary);
END;
...
TYPE nametab IS TABLE OF movies.title%TYPE;
Title_tab nametab;
...
SELECT title BULK COLLECT INTO title_tab FROM movies
ORDER BY rental_count DESC;
...
True (*)
False
Correct
Position A
Position B (*)
Position C
True (*)
False
Correct
True
False (*)
Section 13 Quiz
(Answer all questions in this section)
Correct
An INSTEAD OF trigger
A DML trigger
A DDL trigger
A statement trigger
A Database Event trigger (*)
4. Which of the following are good guidelines to follow when creating a database trigger?
(Choose two.) Mark for Review
(1) Points
5. A business rule states that an employee's salary must be between 4000 and 30000. We
could enforce this rule using a check constraint, but it is better to use a database Mark for Review
trigger. True or False? (1) Points
True
False (*)
Correct
7. User KULJIT creates two triggers named EMP1_TRIGG and EMP2_TRIGG, which
are both DML triggers referencing her EMPLOYEES table. Kuljit now wants to Mark for Review
remove both of these triggers from the database. What command(s) should (1) Points
Kuljit use to do this?
(*)
DROP ALL TRIGGERS ON employees;
DROP TRIGGER emp1_trigg AND emp2_trigg;
DROP TRIGGERS ON employees;
Correct
8. You need to disable all triggers that are associated with DML statements on the
DEPARTMENTS table. Which of the following commands should you use? Mark for Review
(1) Points
9. After the following SQL statement is executed, all the triggers on the
DEPARTMENTS table will no longer fire, but will remain in the database. True or Mark for Review
False? (1) Points
True (*)
False
Correct
Departments 50 and 80 exist but department 81 does not. A user now executes
the following statement:
What happens?
A user now
executes:
UPDATE
employees
SET
department_id
= 50
WHERE
department_id
= 90;
How many
times will the
trigger fire?
Once
Three times (*)
Four times
Five times
Eight times
12. Which of the following can NOT be coded in the body of a DML trigger?
(Choose two.) Mark for Review
(1) Points
14. An AFTER UPDATE trigger can specify more than one column. True or
False? Mark for Review
(1) Points
True (*)
False
Correct
15. The following code will successfully create emp_trigg: True or False?
Mark for Review
CREATE OR REPLACE TRIGGER emp_trigg (1) Points
BEFORE DELETE OF salary ON employees
BEGIN
RAISE_APPLICATION_ERROR(-20202,'Deleting salary is not allowed');
END;
True
False (*)
1. Which
command Mark for Review
would (1) Points
you use
to see if
your
triggers
are
enabled
or
disabled?
DESCRIBE TRIGGER
SELECT trigger_name, trigger_type
FROM USER_TRIGGERS;
SELECT trigger_name, status
FROM USER_TRIGGERS;
(*)
SELECT object_name, status
FROM USER_OBJECTS
WHERE object_type = 'TRIGGER';
Correct
3. You have created several DML triggers which reference your DEPARTMENTS
table. Now you want to disable all of them using a single SQL statement. Which Mark for Review
command should you use? (1) Points
True
False (*)
5. What is wrong with the following code example for a compound trigger?
Mark for Review
CREATE OR REPLACE TRIGGER log_emps (1) Points
FOR UPDATE OF salary ON employees
COMPOUND TRIGGER
TYPE t_log_emp IS TABLE OF log_table%ROWTYPE
INDEX BY BINARY_INTEGER;
log_emp_tab t_log_emp;
AFTER STATEMENT IS
BEGIN
-- some action
END AFTER STATEMENT;
END log_emps;
Declaration
section and at
least one
timing
section. (*)
Declaration
section,
referencing
section, and
timing
sections.
Declaration
section and at
least two
timing
sections.
Declaration
section and all
four timing
sections.
Declaration
section,
timing
sections, and
exception
section.
Correct
7. While editing a
document in Mark for Review
Microsoft Word, (1) Points
you go to the FILE
menu and SAVE
your work. To do
this, Microsoft
Word has executed
an application
trigger. True or
False?
True (*)
False
Correct
8. Which of the
following best Mark for Review
describes a (1) Points
database trigger?
A subprogram
that checks
whether a
user has
typed the
correct
password to
log on to the
database
A subprogram
that is
invoked
explicitly by
the calling
application
A PL/SQL
subprogram
that executes
automatically
whenever an
associated
database
event occurs
(*)
A PL/SQL
subprogram
that always
returns
exactly one
value
A PL/SQL
subprogram
that inserts
rows into a
logging table
Incorrect.
Refer to
Section 13
Lesson 1.
9. What type of
database object Mark for Review
would you create (1) Points
to write an auditing
record
automatically every
time a user
connects to the
database?
A function
A complex
view
A trigger (*)
A package
A procedure
Incorrect.
Refer to
Section 13
Lesson 1.
10. There are five
employees in Mark for Review
department 50. (1) Points
The following
trigger is created:
CREATE TRIGGER
upd_emp
AFTER UPDATE ON
employees
BEGIN
INSERT INTO
audit_table
VALUES (USER,
SYSDATE);
END;
A user now
executes:
UPDATE
employees
SET salary = salary
* 1.1
WHERE
department_id =
50;
One (*)
Two
Five
Six
None of
these.
Correct
11. An
AFTER Mark for Review
UPDATE (1) Points
trigger
can
specify
more
than
one
column.
True or
False?
True (*)
False
Correct
(*)
13. You want to prevent any objects in your schema from being altered or dropped.
You decide to create the following trigger: Mark for Review
(1) Points
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
14. What is the benefit of using the CALL statement in a trigger body?
Mark for Review
(1) Points
It allow both DDL events and database events to be handled by a single
trigger.
It allows the database administrator to monitor who is currently connected
to the database.
It prevents data being read from a mutating table.
It allows the trigger body code to be placed in a separate procedure. (*)
15. The database administrator creates a trigger that automatically disconnects user
HACKER whenever HACKER connects to the database. What type of trigger is Mark for Review
this? (1) Points
A DML trigger
An INSTEAD OF trigger
A Database Event trigger (*)
A DDL trigger
A statement trigger
Section 14 Quiz
(Answer all questions in this section)
1. Which statement for setting a database parameter is the default for remote
dependency checking? Mark for Review
(1) Points
2. Which is not a
mode that can Mark for Review
be used to (1) Points
determine the
dependency
status of
schema
objects when
dealing with
remote
dependencies?
3. With remote
dependencies, Mark for Review
which of the (1) Points
following is
True?
There is one master data dictionary that resides on one server which identifies the status of
all schema objects.
The dependency status is not recorded.
There are two separate data dictionaries on two different servers. (*)
4. A change in a
remote Mark for Review
referenced (1) Points
subprogram is
automatically
recorded as
invalid if its
base object
changes and
that new
status is
relayed to the
dependent
object's status
and
automatically
marked as
invalid. True or
False?
True
False (*)
Incorrect.
Refer to
Section
14
Lesson 2.
5. In this
scenario, Mark for Review
the (1) Points
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 time
stamp of 5
AM and has
a remote
time stamp
of 4 AM
In
Timestamp
Mode,
Procedure
A will
execute
successfully
at 11 AM.
True or
False?
True
False (*)
6. Which of the
following will Mark for Review
display (1) Points
dependency
information
which has
been
generated by
executing the
DEPTREE_FILL
procedure?
(Choose two.)
7. Which data
dictionary Mark for Review
view shows (1) Points
information
about
references
and
dependencies?
DEPTREE
USER_LOCAL_DEPENDENCIES
USER_DEPENDENCIES (*)
USER_REFERENCES
8. A
procedure Mark for Review
includes the (1) Points
following
code:
CURSOR
loc_curs IS
SELECT
location_id,
city,
country_id
FROM
locations;
Which of
the
following
changes to
the
LOCATIONS
table will
allow the
procedure
to be
recompiled
successfully
without
editing its
code?
(Choose
two.)
9. Which of
the Mark for Review
following (1) Points
will NOT
help to
minimize
dependency
failures?
(Choose
two.)
10. PL/SQL
procedure Mark for Review
A invokes (1) Points
procedure
B, which in
turn
invokes
procedure
C, which
references
table T. If
table T is
dropped,
which of
the
following
statements
is true?
True (*)
False
Correct
12. A procedure
includes the Mark for Review
following (1) Points
code:
SELECT
first_name,
salary INTO
v_first_name,
v_salary
FROM
employees
WHERE
employee_id
= 100;
Which of the
following
changes to
the
employees
table will
allow the
procedure to
be
recompiled
successfully ?
(Choose
two.)
The table is dropped but a public table exists with the same name and structure. (*)
The table is dropped.
The table name is changed to newemps.
A new column is added to the table. (*)
The first_name column is dropped from the table.
13. When a
table is Mark for Review
dropped, all (1) Points
PL/SQL
subprograms
that
reference
the table are
automatically
dropped.
True or
False?
True
False (*)
14. Which of
the Mark for Review
following (1) Points
database
objects are
created
when the
utldtree.sql
script is
run?
(Choose
three.)
BEGIN
deptree_fill('TABLE','BOB','DEPARTMENTS');
END;
(*)
BEGIN
utldtree('DEPARTMENTS');
END;
BEGIN
ideptree('TABLE','BOB','DEPARTMENTS');
END;
BEGIN
deptree_fill('TABLE','DEPARTMENTS');
END;
Correct
1. Which of
the Mark for Review
following (1) Points
will NOT
help to
minimize
dependency
failures?
(Choose
two.)
2. View
dept_view is Mark for Review
based on a (1) Points
select from
table
departments.
Procedure
show_dept
contains
code which
selects from
dept_view.
Which of the
following
statements
are true?
(Choose
three.)
(Choose all correct answers)
3. User ALICE
owns a Mark for Review
procedure (1) Points
show_emps
which
references
table
employees.
Which of the
following will
generate
information
that shows
this
dependency?
BEGIN deptree_fill('TABLE','ALICE','EMPLOYEES');
END;
(*)
BEGIN deptree_fill('ALICE','PROCEDURE','SHOW_EMPS');
END;
BEGIN deptree_fill('ALICE','TABLE','EMPLOYEES');
END;
BEGIN deptree_fill('PROCEDURE','ALICE','SHOW_EMPS');
END;
BEGIN deptree_fill('TABLE','EMPLOYEES');
END;
Correct
4. A procedure
show_emps Mark for Review
contains the (1) Points
following
declaration:
CURSOR
emp_curs
IS SELECT
last_name,
salary
FROM
employees;
What will
happen to
the
procedure if
a new
column is
added to
the
employees
table?
The procedure will still be valid and execute correctly because it does not reference the added
column.
The procedure will automatically be dropped and must be recreated.
The procedure will be marked invalid and must be recompiled before it can be reexecuted. (*)
Users' privileges to execute the procedure will automatically be revoked.
5. Which of
the Mark for Review
following is (1) Points
NOT
created
when the
utldtree.sql
script is
run?
6. Package emp_pack
contains two public Mark for Review
procedures: (1) Points
get_emps and
upd_emps. A
separate procedure
emp_proc invokes
emp.pack.get_emps.
The upd_emps
package body code
is now altered, and
the package body
(but not the
package
specification) is
recreated.
emp_proc will be
marked invalid and
needs to be
recompiled. True or
False?
True
False (*)
7. When a
table is Mark for Review
dropped, all (1) Points
PL/SQL
subprograms
that
reference
the table are
automatically
dropped.
True or
False?
True
False (*)
8. Function
FETCH_EMP Mark for Review
references (1) Points
the
EMPLOYEES
table. The
table is
modified by:
ALTER TABLE
employees
ADD (resume
CLOB);
9. A single
PL/SQL Mark for Review
subprogram (1) Points
such as a
procedure
can be both
a referenced
object and a
dependent
object. True
or False?
True
(*)
False
Correct
Which of the
following statements
about dependencies
are true? (Choose
two.)
EMPLOYEES is
referenced by
ED_VIEW. (*)
ED_PROC is
referenced by
ED_VIEW.
ED_CURS is
directly
dependent on
ED_VIEW.
ED_PROC is
indirectly
dependent on
DEPARTMENTS.
(*)
ED_PROC is
directly
dependent on
EMPLOYEES.
Incorrect. Refer
to Section 14
Lesson 1.
11. Procedure B
has the Mark for Review
ZERO_DIVIDE (1) Points
pre-defined
exception
added to its
EXCEPTION
section. It is
compiled
successfully.
In Timestamp
Mode,
Procedure A,
which is
dependent on
remote
Procedure B,
will compile
and execute
successfully.
True or
False?
True
False (*)
12. A change in a
remote Mark for Review
referenced (1) Points
subprogram is
automatically
recorded as
invalid if its
base object
changes and
that new
status is
relayed to the
dependent
object's status
and
automatically
marked as
invalid. True or
False?
True
False (*)
Incorrect.
Refer to
Section
14
Lesson 2.
13. If two
related Mark for Review
objects are (1) Points
in different
databases,
the
dependency
between
them is
automatically
recorded on
the
dependent
object's data
dictionary.
True or
False?
True
False (*)
Incorrect.
Refer to
Section 14
Lesson 2.
Section 15 Quiz
(Answer all questions in this section)
True (*)
False
Correct
DBMS_DDL.CREATE_WRAP
DBMS_DDL.CREATE_WRAPPED (*)
DBMS_DDL.WRAPPED
DBMS_DML.CREATE_WRAP
DBMS_DDL.WRAP_CODE
Incorrect. Refer to Section 15 Lesson 4.
4. If the version and release of the Oracle database in use is 10.2, what statement will
allow syntax available in version 10.2 or later? Mark for Review
(1) Points
Correct
5. Conditional Compilation allows you to include some source code in your PL/SQL
program that may be compiled or may be ignored depending on: Mark for Review
(1) Points
Correct
6. Conditional
compilation Mark for Review
allows you (1) Points
to include
extra code
to help
with
debugging,
which can
be
removed
once errors
are
resolved.
True or
False?
True (*)
False
Correct
True
False (*)
True
False (*)
True (*)
False
Correct
True
False (*)
Incorrect. Refer to Section 15 Lesson 2.
13. Which PL/SQL warning message identifies code that can cause
unexpected behavior or wrong results when executed? Mark for
Review
(1) Points
INFORMATIONAL
SEVERE (*)
ERROR
ALL
PERFORMANCE
DBMS_WARNING.ADD_WARNING_SETTING_CAT
DBMS_WARNING.GET_WARNING_STRING
DBMS_WARNING.SET_WARNING_SETTING_STRING (*)
DBMS_WARNING.GET_WARNING_SETTING_STRING (*)
True (*)
False
Correct
1.The two statements below are
equivalent. True or False? Mark for
Review
DBMS_WARNING.SET_WARNING_SETT (1) Points
ING_STRING
('ENABLE:SEVERE','SESSION');
and
ALTER SESSION
SET PLSQL_WARNINGS =
'ENABLE:SEVERE';
True
False (*)
True
False (*)
ALL
PERFORMANCE
INFORMATIONAL
ERROR
SEVERE (*)
DBMS_WARNING.SET_WARNING_SETTING_STRIN
G (*)
DBMS_WARNING.GET_WARNING_STRING
DBMS_WARNING.GET_WARNING_SETTING_STRIN
G (*)
DBMS_WARNING.ADD_WARNING_SETTING_CAT
Correct
True (*)
False
Correct
6. Native
machine Mark for Review
code (1) Points
PL/SQL
will always
execute
faster than
bytecode
PL/SQL
because it
need not
be
interpreted
at run
time. True
or False?
True (*)
False
Correct
7. Which data dictionary view allows you to see the setting for
PLSQL_OPTIMIZE_LEVEL? Mark for Review
(1) Points
USER_PLSQL_CODE_TYPE
USER_PLSQL_OBJECTS
USER_OBJECT_SETTINGS
USER_PLSQL_OPTIMIZE
USER_PLSQL_OBJECT_SETTINGS (*)
PLSQL_CODE_TYPE
PLSQL_LEVEL
USER_PLSQL_OPTIMIZE
PLSQL_OPTIMIZE_LEVEL (*)
OPTIMIZE_LEVEL
9. For PL/SQL code larger than 32,767 characters, you must use the wrap utility.
True or False? Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
Correct
DBMS_DDL.CREATE_WRAPPED (pkg1);
WRAP pkg1.sql
DBMS_DDL.CREATE_WRAPPED ('CREATE OR REPLACE PACKAGE
BODY pkg1...);
WRAP INAME=pkg1.sql (*)
DBMS_DDL.CREATE_WRAP (pkg1);
True (*)
False
Correct
True
False (*)
$$IF
$$THEN
$$ELSE
$$ELSIF
$$END
$$IF
$$THEN
$$ELSE
$$END
$$DEBUG
$IF
$THEN
$ELSE
$ELSIF
$END
(*)
$IF
$THEN
$ELSE $ELSIF
$ENDIF
$IF
$THEN
$ELSE
$END
$CCFLAG
15. Conditional compilation allows you to include extra code to help with
debugging, which can be removed once errors are resolved. True or False? Mark for Review
(1) Points
True (*)
False
Correct