A collection in binary representation

When the control mode of the query data is in binary representation, the mi_value() or mi_value_by_name() function returns a value status of MI_COLLECTION_VALUE for a collection column. The value buffer contains a pointer to the collection structure for the collection.

You can extract the individual elements from the collection structure with the DataBlade® API collection functions, as follows:
  • The mi_collection_open() function opens the collection that the collection structure describes.
  • The mi_collection_fetch() functions fetches the elements from the collection. The element that mi_collection_fetch() obtains is in its binary representation.
  • The mi_collection_close() function closes the collection that the collection structure describes.
For the collection column that code fragment in A collection in text representation defines, the following code fragment handles the MI_COLLECTION_VALUE value status that mi_value() or mi_value_by_name() returns for a collection column in binary representation:
switch( mi_value(row, i, &colval, &collen) )
   {
   ...
   case MI_COLLECTION_VALUE:
      if ( (colldesc = mi_collection_open(conn,
            (MI_COLLECTION *)colval) != NULL )
         {
         while ( mi_collection_fetch(conn, colldesc, 
               MI_CURSOR_NEXT, 0, (MI_DATUM *)&elmtval,
               &elmtlen) != MI_END_OF_DATA )
            {
            int_val = (mi_integer)elmtval;
            DPRINTF("trc_class", 11, 
               ("Element value=%d\n", int_val));
            }
         }
      break;