Quiz 6

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

1.

 Consider the following code:


DECLARE
 TYPE dept_info_type IS RECORD
  (department_id departments.department_id%TYPE,
  department_name departments.department_name%TYPE);
 TYPE emp_dept_type IS RECORD
  (first_name employees.first_name%TYPE,
  last_name employees.last_name%TYPE),
  dept_info dept_info_type);

 v_dept_info_rec dept_info_type;
 v_emp_dept_rec emp_dept_type;

How many fields can be addressed in v_dept_info_rec?

Mark for Review

(1) Points
four
three
one
two (*)
Correct

2. Which of the following statements about user-defined PL/SQL records is


NOT true?
Mark for Review

(1) Points
It can be used as an OUT parameter in a package procedure.
It must contain one or more components, but all the components must have
scalar datatypes. (*)
It can be defined as NOT NULL.
It can be a component of another PL/SQL record.
It is not the same as a row in a database table.
Correct

3. You can use %ROWTYPE with tables and views.


Mark for Review

(1) Points
True (*)
False
Correct

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

5. Which of the following will successfully create a record type containing


two fields, and a record variable of that type?
Mark for Review

(1) Points
TYPE person_type IS (l_name VARCHAR2(20), gender CHAR(1));
person_rec person_type;
TYPE person_type IS RECORD
(l_name VARCHAR2(20), gender CHAR(1));
person_rec TYPE person_type;
TYPE person_type IS RECORD
(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
6. Identify the valid collection types:
Mark for Review

(1) Points
INDEX BY TABLE OF RECORDS (*)
INDEX BY VIEW
INDEX BY TABLE (*)
INDEX BY TABLE OF ROWS
Correct
7. Which of the following methods can be used to reference elements of an
INDEX BY table? (Choose three.)
Mark for Review

(1) Points
COUNT (*)
EXISTS (*)
PREVIOUS
DROP
FIRST (*)
Correct

8. 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 INDEX BY TABLE OF departments%ROWTYPE
    INDEX BY BINARY_INTEGER;
DECLARE
    TYPE t_depttab IS TABLE OF departments%ROWTYPE
    INDEX BY BINARY_INTEGER; (*)
DECLARE
    TYPE t_depttab IS TABLE OF departments%ROWTYPE
    INDEXED BY NUMBER;
DECLARE
    TYPE t_depttab IS TABLE OF departments%TYPE
    INDEX BY BINARY_INTEGER;
Correct

9. 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
An explicit cursor based on SELECT * FROM employees;
A record
An INDEX BY table of records (*)
An INDEX BY table
Correct

10. An INDEX BY TABLE must have a primary key.


Mark for Review

(1) Points
True (*)
False
Correct
Previous
11. An INDEX BY TABLE primary key cannot be negative.
Mark for Review

(1) Points
True
False (*)
Correct

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

13. In an INDEX BY table of records the record can be


_______________________.
Mark for Review

(1) Points
a user-defined record
%ROWTYPE
Either one. (*)
Incorrect. Refer to Section 6 Lesson 2.
14. 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

15. Which of these PL/SQL data structures can NOT store a collection?


Mark for Review

(1) Points
An INDEX BY table of records
An INDEX BY table indexed by PLS_INTEGER
A PL/SQL record (*)
An INDEX BY table indexed by BINARY_INTEGER
Correct
Previous

1. Which of the following methods can be used to reference elements of an


INDEX BY table? (Choose three.)
Mark for Review

(1) Points
PREVIOUS
FIRST (*)
COUNT (*)
EXISTS (*)
DROP
Correct
2. An INDEX BY TABLE type can only have one data field.
Mark for Review

(1) Points
True (*)
False
Correct

3. In an INDEX BY table of records the record can be


_______________________.
Mark for Review

(1) Points
%ROWTYPE
Either one. (*)
a user-defined record
Correct

4. Which of these PL/SQL data structures can NOT store a collection?


Mark for Review

(1) Points
A PL/SQL record (*)
An INDEX BY table of records
An INDEX BY table indexed by BINARY_INTEGER
An INDEX BY table indexed by PLS_INTEGER
Correct

5. An INDEX BY TABLE primary key cannot be negative.


Mark for Review

(1) Points
True
False (*)
Correct
6. What is the largest number of elements (i.e., records) that an INDEX BY
table of records can contain?
Mark for Review
(1) Points
Many millions of records because a BINARY_INTEGER or PLS_INTEGER can
have a very large value (*)
4096
100
None of these.
32767
Correct

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

8. Identify the valid collection types:


Mark for Review

(1) Points
INDEX BY VIEW
INDEX BY TABLE OF RECORDS (*)
INDEX BY TABLE OF ROWS
INDEX BY TABLE (*)
Correct

9. 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 INDEX BY TABLE OF departments%ROWTYPE
    INDEX BY BINARY_INTEGER;
DECLARE
    TYPE t_depttab IS TABLE OF departments%ROWTYPE
    INDEXED BY NUMBER;
DECLARE
    TYPE t_depttab IS TABLE OF departments%TYPE
    INDEX BY BINARY_INTEGER;
DECLARE
    TYPE t_depttab IS TABLE OF departments%ROWTYPE
    INDEX BY BINARY_INTEGER; (*)
Correct

10. 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
An explicit cursor based on SELECT * FROM employees;
A record
An INDEX BY table of records (*)
An INDEX BY table
Correct
Previous
11. Which of the following will successfully create a record type containing
two fields, and a record variable of that type?
Mark for Review

(1) Points
TYPE person_type IS (l_name VARCHAR2(20),gender CHAR(1));
person_rec TYPE person_type;
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 RECORD
(l_name VARCHAR2(20),gender CHAR(1));
person_rec person_type; (*)
Correct
12. The following code declares a PL/SQL record with the same structure as
a row of the departments table. True or False?
DECLARE
    v_dept_rec departments%ROWTYPE;
...

Mark for Review

(1) Points
True (*)
False
Correct

13. Which of the following statements about user-defined PL/SQL records is


NOT true?
Mark for Review

(1) Points
It is not the same as a row in a database table.
It can be a component of another PL/SQL record.
It can be used as an OUT parameter in a package procedure.
It must contain one or more components, but all the components must have
scalar datatypes. (*)
It can be defined as NOT NULL.
Correct

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

15. You can use %ROWTYPE with tables and views.


Mark for Review

(1) Points
True (*)
False
Correct
Previous

You might also like