1 It
is a composite data type.
2 Here
composite data type is composed of one or more fields that is it consists of
one or more than one fields in it.
3 A
procedure is also a composite data type, here collection is also a composite
data type.
Why to use Collections?.
One of the reason for using the collections is
“Performance Optimization”. The following are some of the Use cases for
performance optimizations
1 To
select and collect the data in bulk.
2 To
insert, update and delete more than one rows (multiple rows).
3 To
return the bulk data in “Functions”.
Basic Terminology:
Index value:
it’s an integer, sometimes a String based on
the type of collection.
Element:
Elements in the collections are
always same data types. (Records, Strings, dates etc.)
Sparse and Dense:
A Collection is said to be Sparse if there are
no index values defined in between range of the index values. Example: if an
element in collection is assigned with the index value 24 and another index
value 30. So there are no elements in the collection with index values in
between 24 and 30. This type of collections are called as Sparse Collection.
Where the Dense Collections has the elements with the index values up to 30.
Method:
Methods in the collections may be
“Functions” and “Procedures”. They are attached to the variable in the
collection by dot (.) annotation. They are used to manipulate the contents or
information of the collection.
Following are the list of Methods
:
1 EXISTS(n).
2 Count
3 Delete
4 First
5 Last
6 Trim
7 Prior(n)
8 Next(n)
9 Extend
1 Extend(n)
1 Extend(n1.n2)
Trim(n)
1 Delete(n)
1Delete(n1,n2)
Types of Collections:
Each Collection type is with
specific characteristics and used in different scenarios. There are three
different types of Collections.
1 Associated
array (Index Based).
2 Nested
Tables.
3 Varray.