For a deferred column, the provider is not required to retrieve data from the data source until IRowset::GetData is called for that column, or, if the column contains an OLE object, until a method used to access that object is called. It is provider specific when the data in a deferred column is actually retrieved. For example, it might be retrieved when the command is executed, when the row handle is fetched, lazily in the background, or when GetData or a method on another interface is called for the column. If a column is deferred, the DBCOLUMNFLAGS_MAYDEFER enumerated type flag returned by IColumnsInfo::GetColumnsInfo is set for the column.
Whether the data for a deferred column is cached depends on the setting of the DBCOLUMNFLAGS_CACHEDEFERRED flag returned by GetColumnsInfo. If this flag is set, the column value is cached when first read. The cached value is returned whenever the column is read. It can be changed by calling IRowsetChange::SetData or IRowsetRefresh::RefreshVisibleData and is released only when the row handle is released. If the DBCOLUMNFLAGS_CACHEDEFERRED flag is not set, then multiple calls to GetData (or the method used to read the column, if the column contains OLE objects) can return different values. Such calls are not guaranteed to reflect a change to the underlying column unless RefreshVisibleData has been called.
To use a deferred column, the consumer sets the DBPROP_DEFERRED property; columns that contain OLE objects are deferred by default.
The consumer should be aware of an increased isolation risk of using deferred columns because deferred data might be read at a different time than nondeferred data. If the consumer is not using Repeatable Read isolation or better, then it may encounter discrepancies between the original and the deferred access to a row. In particular, the consumer may find that the column is missing because the row has been deleted, or the column may not match the rest of the row. Under some circumstances, use of a row version column in conjunction with both original and deferred access can be used to warn a consumer about a situation where a concurrent error has occurred; a consumer can determine whether a column contains a row version with the DBCOLUMNFLAGS_ISROWVER flag in GetColumnInfo.