Array variables
In addition to normal scalar variables, NZPLSQL also supports array
variables. To declare an array variable, use the following syntax:
name VARRAY(size) OF type;
All of the elements of the array are initially set to the SQL NULL
value for the declared type. To assign a value to an element, do the following:
name(idx) := value;
This syntax raises an exception if the index (idx) is out of bounds.
The following methods are supported:
name.EXTEND(size)
name.COUNT
name.TRIM(size)
The EXTEND method extends the array by the specified size. If size is omitted, the default is 1.
COUNT returns the number of elements in the array.
TRIM deletes the last size elements in the array (the default is 1). TRIM and EXTEND raise an exception if size is out of bounds.
Array references are allowed almost anywhere variable references
are allowed, with the following exceptions:
- As an argument to RAISE
- As an INTO variable
- As the variable in a FOR LOOP
- As part of a default value