Values can be assigned to associative arrays using subindices
and literal values.
About this task
You would perform this task before performing SQL PL that
is conditional on the variable having an assigned value or before
passing the variable as a parameter to a routine.
Procedure
- Define a SET statement.
- Specify the array variable name.
- Specify the assignment symbol, '=".
- Specify the ARRAY keyword and specify within the required
brackets sets of paired values.
- Execute the SET statement.
Example
The following is an example of how to assign element values
to an array named,
myArray:
SET myArray[1] = 123;
SET myArray[2] = 124;
...
SET myArray[100] = 223;
What to do next
If the SET statements execute successfully, the array
elements have been defined successfully. To validate that the array
was created you can attempt to retrieve values from the array.
If
the SET statement failed to execute successfully:
- Verify the SQL statement syntax of the SET statement and execute
the statement again.
- Verify that the data type was created successfully.