Semester 1 Final
Semester 1 Final
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
You can use a single cursor to fetch a different set of rows each time the
cursor is opened. (*)
Correct
p_job_id VARCHAR2(25)
p_job_id
job_id VARCHAR2
Correct
3.Which of the following is a good reason to declare and use multiple cursors in
Mark for Review
a single PL/SQL block?
(1) Points
Multiple cursors allow us to fetch rows from two or more related tables
without using a JOIN. (*)
Multiple cursors can be opened many times, while a single cursor can be
opened only once.
Multiple cursors are the only way to use cursors with parameters.
Multiple cursors improve performance. They are faster than using a single
cursor.
Correct
4.Which of the following is NOT allowed when using multiple cursors with
Mark for Review
parameters?
(1) Points
Correct
5.Which of these constructs can be used to fetch multiple rows from a cursor's
Mark for Review
active set?
(1) Points
A CASE statement
A basic loop which includes FETCH and EXIT WHEN statements (*)
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
The block will fail because you can not use a WHILE loop with an explicit
cursor.
Correct
7. After a cursor has been closed, it can be opened again in the same PL/SQL
Mark for Review
block. True or False?
(1) Points
TRUE (*)
FALSE
Correct
8. Which statement correctly places the employee id and last name into the
Mark for Review
stated variables?
(1) Points
DECLARE
CURSOR emp_cursor IS
SELECT employee_id, last_name FROM employees
WHERE department_id = 30;
v_empno employees.employee_id%TYPE;
v_lname employees.last_name%TYPE;
BEGIN
OPEN emp_cursor;
-- Point A
...
Correct
When the cursor is opened and rows are fetched, what is locked?
Nothing is locked because the cursor was not declared with NOWAIT.
Correct
After opening the cursor and fetching some rows, you want to delete
the most recently fetched row. Which of the following will do this
successfully?
None of these.
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 5 Quiz
The server will wait until the locks have been released by the other user.
Your rows will override the other user's lock and your block will execute
successfully.
Correct
employees.salary
emp_record.employees.salary
TO_CHAR(salary)
emp_cursor.salary
emp_record.salary (*)
Correct
13.A cursor FOR loop using a subquery can shorten code length when compared
Mark for Review
to an explicit cursor declaration. True or False?
(1) Points
True (*)
False
Correct
emp_rec emp_rec%ROWTYPE;
emp_rec emp_curs%TYPE;
emp_rec cursor%ROWTYPE;
Correct
Scalar
Cursor
Row
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
1.Which of the following will successfully create a record type containing two
Mark for Review
fields, and a record variable of that type?
(1) Points
(*)
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 person_type;
TYPE person_type IS (l_name VARCHAR2(20),
gender CHAR(1));
person_rec TYPE person_type;
Correct
2.The following code declares a PL/SQL record with the same structure as a row
Mark for Review
of the departments table. True or False?
(1) Points
DECLARE
v_dept_rec departments%ROWTYPE;
...
True (*)
False
Correct
True (*)
False
Correct
Correct
v_emp_dept_rec emp_dept_type;
one
three
four (*)
two
Correct
Section 6 Quiz
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 INDEX BY TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
DECLARE
TYPE t_depttab IS TABLE OF departments%ROWTYPE
INDEX BY BINARY_INTEGER;
(*)
7. To declare an INDEX BY table, we must first declare a type and then declare a
Mark for Review
collection variable of that type. True or False?
(1) Points
True (*)
False
Correct
8. An INDEX BY TABLE primary key cannot be negative.
Mark for Review
(1) Points
True
False (*)
Correct
Correct
COUNT (*)
FIRST (*)
DROP
EXISTS (*)
PREVIOUS
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 6 Quiz
11.Which of these PL/SQL data structures could store a complete copy of the
Mark for Review
employees table, i.e., 20 complete table rows?
(1) Points
A record
An INDEX BY table
Correct
a user-defined record
True (*)
False
Correct
INDEX BY VIEW
Correct
15.An INDEX BY TABLE type can only have one data field.
Mark for Review
(1) Points
True (*)
False
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Quiz
1.Examine the following code. Why does this exception handler not follow good
Mark for Review
practice guidelines? (Choose two.)
(1) Points
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;
2.Which of the following are good practice guidelines for exception handling?
Mark for Review
(Choose three.)
(1) Points
Test your code with different combinations of data to see what potential
errors can happen. (*)
TRUE (*)
FALSE
Correct
4.While a PL/SQL block is executing, more than one exception can occur at the
Mark for Review
same time. True or False?
(1) Points
TRUE
FALSE (*)
Correct
RAISE_APPLICATION_ERROR(-29001,'Error Raised');
RAISE_APPLICATION_ERROR('Error Raised',-20257);
RAISE_APPLICATION_ERROR('Error Raised',-22001);
Correct
Test: Section 7 Quiz
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Quiz
True
False (*)
Correct
7. Department-id 99 does not exist. What will be displayed when the following
Mark for Review
code is executed?
(1) Points
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;
None of these.
Correct
8. What is a?
Mark for Review
(1) Points
Correct
OTHERS
NO_DATA_FOUND (*)
E_INSERT_EXCEP
ZERO_DIVIDE (*)
TOO_MANY_ROWS (*)
Correct
User-defined errors
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 7 Quiz
11.Examine the following code. At Line A, you want to raise an exception if the
Mark for Review
employee's manager_id is null. What kind of exception is this?
(1) Points
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 constraint violation
A NO_DATA_FOUND exception
Correct
An error occurred
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;
...
Correct
True (*)
False
Correct
15.What will happen when the following code is executed?
Mark for Review
(1) Points
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 declare more than one
exception in the same block.
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
1.Suppose you set up a parameter with an explicit IN mode. What is true about
Mark for Review
that parameter?
(1) Points
It cannot have a DEFAULT value.
Correct
Correct
W(rite)
OUT (*)
IN
CONSTANT
R(ead)
Correct
Correct
defproc;
Correct
Review your answers, feedback, and question scores below. An asterisk (*) indicates a correct answer.
Section 8 Quiz
It passes a value into the procedure when the procedure is invoked. (*)
Correct
Correct
(v_num NUMBER(4,2))
(v_num NUMBER(6,2))
(v_num)
Correct
myproc(v_left, 30);
myproc(v_left, v_right);
Correct
10.What is the correct syntax to create procedure MYPROC that accepts two
Mark for Review
number parameters X and Y?
(1) Points
Correct