Chapter 18 Collections


Lab 18.1 Self-Review Answers

A5:

Questions

Answers

Comments

1)

A

 

2)

C

You will recall that a following is always used in an index-by table declaration

 INDEX BY BINARY_INTEGER; 

3)

A

A nested table is automatically NULL when it is declared. As a result, it must be initialized prior to its use.

4)

C

If a PL/SQL table contains only one element, it is its first and last element. As a result, the FIRST method returns the subscript of the first element, 1, and the LAST method returns the subscript of the last element, 1.

5)

C

It is important to remember that a PL/SQL table in this case is a nested table. You will recall that the DELETE method cannot be used with a nested table.


Lab 18.2 Self-Review Answers

A5:

Questions

Answers

Comments

1)

A

You will recall that using a DELETE method on varrays causes a syntax error because varrays are dense.

2)

B

A varray can contain a number of elements, varying from zero (empty array) to its maximum size. In other words, an upper bond of the array can be extended to its maximum size.

3)

A

 

4)

C

The COUNT method returns the current number of varray elements, and the LIMIT method returns the maximum number of elements that a varray can contain.

5)

D

Because varrays cannot be sparse, a DELETE method causes a syntax error when it is issued against a varray.


Lab 18.3 Self-Review Answers

A5:

Questions

Answers

Comments

1)

A

 

2)

B

Regardless of its element type, an upper bound of a varray can be extended to its maximum size.

3)

B

A nested table must be initialized prior to its use regardless its element data type.

4)

C

Consider the statement

 varray2(2)(3) 

In this statement you are referencing the second element of varray2 and third element of varray1. Each element of varray2 is a varray of three integers defined as varray1 . Recall the following declaration statement:

 varray2 varray_type2 :=    varray_type2(varray1, varray_type1    (4, 5, 6)); 

where varray_type1(4, 5, 6) is the second element of the varray2 . Notice that the third element of varray1 is 6. As a result, the variable var1 is assigned a value of 6.

5)

B

You will recall that the PL/SQL block contains the following statements:

 varray2.EXTEND; varray2(3) := varray_type1(0); varray2(3).EXTEND; 

The first statement increases the size of the varray2 . In other words, this statement adds the third element to the collection. The second statement initializes the third element of the varray2 via constructor associated with the varray type varray_type1 . This is done because each element of the varray2 is a varray of three integers. This adds one element to the varray1 . The third statement increases the size of the varray1 by adding a placeholder for the second element. In other words, it adds the second element to the third element of varray2 .




Oracle PL[s]SQL by Example
Oracle PL[s]SQL by Example
ISBN: 3642256902
EAN: N/A
Year: 2003
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net