ESQL/C host variables as elements

You can use the Informix® ESQL/C host variable to specify an element of a collection variable.

The host variable must be declared with a data type that is compatible with the element type of the collection and must contain a value that is also compatible. For example, the following INSERT statement uses a host variable to insert a single value into the same a_set variable as in the preceding example:
an_int = 6;
EXEC SQL insert into table(:a_set) values (:an_int);

To insert multiple values into a collection variable, you can use an INSERT statement for each value or you can declare an insert cursor and use the PUT statement.

The following UPDATE statement uses a host variable to update all elements in the a_set collection to a value of 4:
an_int = 4;
EXEC SQL update table(:a_set) (an_element) 
   set an_element = :an_int;

To update multiple values into a collection variable, you can declare an update cursor and use the WHERE CURRENT OF clause of the UPDATE statement.