DECLARE identifier(bound-pair,…)[attribute…];
Or
DECLARE(declaration,…)(bound-pair,…)[attribute…];
DECLARE SALARIES(200) FIXED DECIMAL(6,2);
In the previous example, the DECLARE statement declares a 200-element array with the identifier SALARIES. Each element of the array is a fixed-point decimal number with a total of six digits, two of which are fractional.
The identifier in the previous statement can be replaced with a list of declarations, to declare several objects with the same attributes, as shown in the following example:
DECLARE (SALARIES,PAYMENTS) (100) FIXED DECIMAL(6,2);
This declaration declares SALARIES and the array PAYMENTS with the same dimensions and the same type.
DECLARE TOTALS(*,*) FIXED BINARY(15);
This declaration declares TOTALS with two subscripts, each with variable extents. Note that TOTALS must be a parameter.
Description
The declaration of an array specifies the dimensions of the array and the bounds of each dimension.
One bound-pair is specified for each dimension of the array. The number of elements per dimension is defined by the bound pair. The extent of the array is the product of the numbers of elements in its dimensions. If the lower bound is omitted, the lower bound for that dimension is 1 by default.
The asterisk (*) can be used as the bound pair when arrays are declared as parameters of a procedure. The asterisk causes the indicated parameter subscript to be the same bound pair as the corresponding argument subscript. (If one dimension is specified with an asterisk, then all dimensions must be so specified.)