To update a particular element in a collection, declare
an update cursor for the collection host variable.
About this task
An update cursor for a collection variable is a
select cursor that was declared with the FOR UPDATE keywords. The
update cursor allows you to sequentially scroll through the elements
of the collection and update the current element with the UPDATE...WHERE
CURRENT OF statement.
To update elements, follow these steps:
Procedure
Create a client collection variable in your HCL
OneDB™ ESQL/C program.
Declare the update cursor for the collection variable
with the DECLARE statement and the FOR UPDATE clause; open this cursor
with the OPEN statement.
By default, a select cursor
on a collection variable supports updates. For more information
about how to declare a select cursor, see ids_esqlc_0309.html#ids_esqlc_0309.
Fetch the element or elements from the collection variable
with the FETCH statement and the INTO clause.
Close the update cursor with the CLOSE statement, and if
you no longer need the cursor, free it with the FREE statement.
Results
The application must position the update cursor on the
element to be updated and then use UPDATE...WHERE CURRENT OF to update
this value.
The HCL
OneDB ESQL/C program
in the following figure uses an update cursor to update an element
in the collection variable, a_set, and then to update
the set_col column of the tab_set table (see ids_esqlc_0296.html#ids_esqlc_0296__sii-09-40233).