Using the large object manager

The ITLargeObjectManager class performs simple operations on large objects such as creating, opening, reading, and seeking.

The functionality of the ITLargeObjectManager class is only supported with HCL Informix® databases.

Generally, this class is not used directly, but is included as a member of some class that implements a database type that has one or more large objects within it. For instance, a server sound data type might have a large object that holds the digitized waveform. The C++ type implementation must know how to read that large object. By using an ITLargeObjectManager as a member, the implementor of the data type can use code from the ITLargeObjectManager class implementation.

The application can use ITLargeObjectManager::CreateLO() to create a large object. It can then get the handle of the newly created large object in either text or binary form by using ITLargeObjectManager::HandleText() or ITLargeObjectManager::Handle() and insert it into a table. These operations must occur within the same transaction; otherwise the large object falls prey to garbage collection.

You can perform operations on large objects within a fetched row even though the connection is still checked out (locked). A connection is checked out after the ITQuery::ExecForIteration() method returns multiple rows in the result set. It remains checked out until either the last row in the result set has been fetched with ITQuery::NextRow() or the query processing has been terminated by calling ITQuery::Finish(). While a connection is checked out, no other query can be executed on that connection.

The following excerpt from loadtab.cpp illustrates the use of the ITLargeObjectManager.

To use the ITLargeObjectManager, the application creates an instance of it on an opened connection object. The CreateLO() method creates the large object and sets the handle of the ITLargeObjectManager to the new large object.

The Write() method writes the string pointed to by pdb into the large object from the current position (in this case from the beginning of the string).

Finally, the statement parameter is set to the value of the large object handle, retrieved in text format by calling ITLargeObj.
ITLargeObjectManager lobMgr(conn);
    lobMgr.CreateLO();
    lobMgr.Write(pdb, strlen(pdb));

    if (!param->FromPrintable(lobMgr.HandleText()))
        {
        cerr 
            << "Could not set LOB parameter " 
            << paramno << " to ’" << pdb << "’" << endl;
        return -1;
        }
    }
else if(param->TypeOf().Name().Equal("byte"))
    {
    ITDatum *pdatum = 0;
    param->QueryInterface(ITDatumIID, (void **)&pdatum);
    if(!pdatum)
        {
        cerr << "BYTE type does not expose ITDatum???" << endl;
        return -1;
        }
    if(!pdatum->SetData(pdb, pdbpos, 0))
        {
        cerr << "SetData() for BYTE failed" << endl;
        return -1;
        }
    pdatum->Release();
    }
else if (null == TRUE)
    { 
    if (!param->SetNull())
        {
        cerr << "Could not set parameter " 
             << paramno << " to null" << endl;
        return -1;
        }
    }