Assigning array values using the subindex and literal values

Values can be assigned to associative arrays using subindices and literal values.

Before you begin

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

  1. Define a SET statement.
    1. Specify the array variable name.
    2. Specify the assignment symbol, '=".
    3. Specify the ARRAY keyword and specify within the required brackets sets of paired values.
  2. 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.