The mi_collection_insert() function

The mi_collection_insert() function inserts a single element into a collection.

Syntax

mi_integer mi_collection_insert(conn, coll_desc, insrt_datum, action, jump)
   MI_CONNECTION *conn;
   MI_COLL_DESC *coll_desc;
   MI_DATUM insrt_datum;
   MI_CURSOR_ACTION action;
   mi_integer jump;
conn
A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
coll_desc
A pointer to the collection descriptor.
insrt_datum
The MI_DATUM value to contain the collection element that mi_collection_insert() inserts.
action
This value determines the orientation of the insertion. When a collection opens, elements are available in a cursor. The current cursor position is before the first element. Possible action values follow:
MI_CURSOR_NEXT
Inserts an element after the current cursor position.
MI_CURSOR_PRIOR
Moves back one element and inserts an element before this new cursor location.
MI_CURSOR_FIRST
Inserts an element before the first element.
MI_CURSOR_LAST
Inserts an element after the last element.
MI_CURSOR_ABSOLUTE
Moves jump elements from the beginning of the cursor and inserts an element before the new cursor position.
MI_CURSOR_RELATIVE
Moves jump elements from the current position and inserts an element before this new cursor position.
MI_CURSOR_CURRENT
Inserts an element before the current cursor position.
jump
The absolute or relative offset of the insertion for LIST collections only. If action is not MI_CURSOR_ABSOLUTE or MI_CURSOR_RELATIVE when jump is specified, the function raises an exception and returns MI_NULL_VALUE.

For absolute positioning, a jump value of 1 The first element.

Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_collection_insert() function inserts the element that insrt_datum references into the open collection that coll_desc references. The action argument determines where the new element value is inserted. This function inserts the specified element into the collection cursor associated with coll_desc and obtains the element to insert from an MI_DATUM value that insrt_datum references.

For descriptions of collections and of MI_DATUM values, see the HCL OneDB™ DataBlade® API Programmer's Guide.

Return values

MI_OK
The function was successful.
MI_NULL_VALUE
This value is returned when jump is not zero and the collection is not a list.
MI_ERROR
The function was not successful.