Update a nested collection
If you want to update a collection of collections, you must declare a cursor to access the outer collection and then declare a nested cursor to access the inner collection.
For example,
suppose that the manager table has an additional column, scores,
which contains a LIST whose element type is a MULTISET of integers,
as the following figure shows.
To update a value in the MULTISET, declare a cursor that
moves through each value in the LIST and a nested cursor that moves
through each value in the MULTISET, as the following figure shows.
The SPL function selects each MULTISET in the scores column
into l, and then each value in the MULTISET into m.
If a value in m is
0
, the function deletes
it from the MULTISET. After the values of 0
are deleted,
the function counts the remaining elements in each MULTISET and returns
an integer.Tip: Because this function returns a value
for each MULTISET in the LIST, you must use a cursor to enclose the
EXECUTE FUNCTION statement when you execute the function.