Search code examples
cesentextensible-storage-engine

What type of value returns JetRetrieveColumns when itagSequence = 0 on multivalued column?


I want to know how many values multivalued column have. MSDN says "itagSequence here in the JET_RETRIEVECOLUMN can be 0. If the itagSequence is 0 then the number of instances of a multi-valued column are returned instead of any column data." (when we use JetRetrieveColumns function) But what is data type of value to be returned?

JET_RETRIEVECOLUMN j_rc;
j_rc.columnid = j_cb.columnid; // j_cb is of type JET_COLUMNBASE
j_rc.grbit = NULL;
j_rc.pvData = // pointer to buffer for storing data
j_rc.cbData = // size of data

Checking if column is multivalued

if (j_cb.grbit & JET_bitColumnMultiValued) { 

Retrieving quantity of values in multivalued column


        j_rc.itagSequence = 0;
        JetRetrieveColumns(sessionID, tbl_cursor, &j_rc, 1);
        ...
}

So what is type of data to be returned?


Solution

  • MSDN about JetRetrieveColumns: "On success, columns data and column size are returned in provided buffers described in array of JET_RETRIEVECOLUMN structures. If an itagSequence was set to 0 (zero) to indicate that the number of instances of a multi-valued field was desired instead of column data, then the number of instances of a multi-valued column is returned in the itagSequence field itself. Each JET_RETRIEVECOLUMN structure has an error field that contains warnings for the column retrieved. If the column was NULL valued, then the error code will be set to JET_wrnColumnNull." By the way itagSequence is of type unsigned long. Thanks to Paul Ogilvie for pointing me to the answer:)