Modifying Elements in a Collection Variable
To update an element of a collection within an SPL routine, you must first declare a cursor with the FOREACH statement.
Then, within the FOREACH loop, select elements one at a time from the collection variable, using the collection variable as a collection-derived table in a SELECT query.
When the cursor is positioned on the element to be updated, you
can use the WHERE CURRENT OF clause, as follows:
- The UPDATE statement with the WHERE CURRENT OF clause updates the value in the current element of the collection variable.
- The DELETE statement with the WHERE CURRENT OF clause deletes the current element from the collection variable.