Using ARRAY objects in stored procedures
ARRAY
as a data type was introduced in DB2 9.5. An array is a set of identical data elements. These base elements are based on inbuilt data types. Any element in an array can be identified by its index position. Arrays are very useful when we need to store a set of values. This becomes very useful when we need to pass a set of values to a procedure. Instead of passing many parameters simultaneously, we can pass one array to the procedure. For example, if we want to pass in a list of employee numbers as input to a procedure, then we can keep them in an array and pass this array as an input parameter. The same concept applies when getting the results from a procedure. In this recipe, we will see how we can create and use arrays in stored procedures.
How to do it...
1. Create a variable of the type
ARRAY:
The main use of theARRAY
type in a procedure is as an input or output parameter. Before we can define any procedure withARRAY
type parameters, we...