Insert a collection into the outer collection
Inserting a SET into the LIST is similar to inserting a single value into a simple collection.
To insert a SET into the LIST, declare a collection variable to hold the LIST and select the entire collection into it. When you use the collection variable as a collection-derived table, each SET in the LIST becomes a row in the table. You can then insert another SET at the end of the LIST or at a specified point.
For example, the twin_primes column
of one row of numbers might contain the following LIST, as the following
figure shows.
If you think of the LIST as a collection-derived table,
it might look similar to the following.
You might want to insert the value
"SET{17,19}"
as
a second item in the LIST. The statements in the following figure
show how to do this.In the INSERT statement, the VALUES clause inserts the
value
SET {17,19}
at the second position of the LIST.
Now the LIST looks like the following figure.You can perform the same insert by passing a SET to an
SPL routine as an argument, as the following figure shows.
In add_set(), the user supplies a SET to add to the LIST and an INTEGER value that is the id of the row in which the SET will be inserted.