PLSQL Programming Flashcards

1
Q

Composite Data Types and type names

A

Stores values that have internal components. You can pass entire composite variables to sub programs and parameters. Can access internal components of composite variables individually

Collection
Record

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Collection Data Type (composite)

A

Internal components always have the same data types and are called (elements). You can access each element of a collection variable by its unique index. Variable_name (index).

Create a collection
Create a variable of that type or use %TYPE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Record Data Type (composite)

A

Data Type can be visualized as a row of data. It can contain all the contents of a row.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
Collection Types (composite). Variable (index)
3 Types
A

Associative Array

Nested Tables

Varray (Variable Size Arrays)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dense & Sparse

A

Are the values of performance settings of the underlying data structure called dimensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Dense

A

If all the rows between the first and last row are defined and given a value (including nulls)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Sparse

A

Not defined or populated sequentially Gaps between defined rows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Associative Array - collection –> composite

A

Sparse or dense index by integer or string. Originally only one and table or index by table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Example of Associative array

A

Creating an index by table keys of subscript type and associated values element type

Syntax
TYPE Type_name is TABLE OF element_type (NOT NULL)
INDEX BY subscript_type
Table_name type_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Nested Tables - collection –> composite

A

This is like a one dimensional array with an arbitrary number of elements.

Differs from an array in the following aspects

  1. Array has a declared number of elements Nested doesn’t. Nested can increase dynamically.
  2. Array is always dense, consecutive scripts. Nested dense initially but can become sparse when elements are deleted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Nested table is similar to declaration of an index-by table but no index by.
Can store in a DB column used for simplifying
Join a single column table with a larger table

Associative array can’t be stored in DB

A

Syntax
TYPE Type_name is Table OF element_type (NOT NULL)
Table_name type_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Varrays (variable size array) - collection –> composite

A

Always dense, can’t delete values in between the values only delete from the end.

Similar to a nested table except must specify upper bound in declaration. Can store in DB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When should you use VARRAY

A

Know the max number of elements
Usually access the elements sequentially

Have to store or retrieve all elements at same time, might be impractical for large numbers of elements.

Syntax
TYPE Type_name is VARRAY(size) OF element_type (NOT NULL)
Table_name type_name := type_name();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Characteristics of Collection

A

Collection # of Subscript Dense or Where Obj type
elements type Sparse Created Attribute
———————————————————————-
Associative -unbound -string -Either -PLSQL No
Array or integer block
———————————————————————-
Nested -unbound -integer -starts dense -PLSQL Yes
Table can become block
sparse or at
Schema level
———————————————————————-
Varray -bounded -integer -dense -PLSQL or Yes
Schema level

Farrah

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Collection Methods (15)

E C L F L P N E E E T T D D D

A

EXISTS(n) - rtn TRUE if specified element exists
COUNT - rtn number of elements in collection
LIMIT - rtn max number of elements for VARRAY or null for nest tables
FIRST - rtn index of the first element in the collection
LAST - rtn index of the last element in the collection
PRIOR(n) - rtn index of the the element prior to specified element
NEXT (n) - rtn index of the next element after the specified element
EXTEND - append a single null element to the collection
EXTEND(n) - appends n null elements to the collection
EXTEND (n1,n2) - appends n1 copies of the n2th element of the collec
TRIM - removes a single element from the end of the collection
TRIM(n) -removes n elements from the collection
DELETE -removes all elements from the collection
DELETE(n) -removes element n from the collection
DELETE(n1,n2) -removes all elements from n1 to n2 from the collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly