Home | Previous Page | Next Page   Data Manipulation > Using Complex Data Types > Collections >

Creating a Collection

To create a collection, use the mi_collection_create( ) function. The mi_collection_create( ) function is the constructor function for the collection structure (MI_COLLECTION). The collection structure includes the type of collection (LIST, MULTISET, or SET) and the element data type.

The following code shows an example of how to use the mi_collection_create( ) function to create a new list of integers:

/*
 * Create a LIST collection with INTEGER elements 
 */
   MI_CONNECTION *conn;
   MI_TYPEID *typeid;
   MI_COLLECTION *coll;

   typeid = mi_typestring_to_id(conn, "list(integer not null)");

   if ( typeid != NULL )
      {
      coll = mi_collection_create(conn, typeid);
   ...
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]