The ITContainer interface

The ITContainer interface is exposed by a value object that contains other objects and does not support a concept of current position within the set. Instead, the ITContainer interface uses an index to extract the corresponding object.

The ITContainer object can be exposed to enable applications to use the ITContainerIter class to iterate over the result set and extract values into C++ base type host variables.

The example program fsexamp1.cpp builds a temporary ITContainerIter object to iterate over the result row of a query returned by ITQuery::ExecOneRow. The ITContainerIter object constructor implicitly extracts an ITContainer interface from the object it is constructed against, or an ITContainCvt interface if possible. The approach illustrated by the fsexamp1.cpp example is more efficient than that used by the tabcnt.cpp example (which performs similar processing).

The following code excerpts point out relevant passages from the fsexamp1.cpp example.
  1. Build the query object.
    ITQuery q(conn);
  2. Issue the query.
    ITRow *row =
        q.ExecOneRow("select unique count(*) from systables where tabname 
            in (’systables’, ’syscolumns’, ’sysviews’);");
    
    if (q.Error())
        {
        // some error processing row
        cerr << q.ErrorText() << endl;
        return 1;
        }
  3. Build an ITContainerIter object on the result row, and extract a C++ int value.
    int numtabs;
    ITContainerIter(row) >> numtabs;
  4. Release the underlying row.
    row->Release();