Returns a rowset containing metadata about each column in the current rowset. This rowset is known as the column metadata rowset and is read-only.
HRESULT GetColumnsRowset ( IUnknown *pUnkOuter, DBORDINAL cOptColumns, const DBID rgOptColumns[], REFIID riid, ULONG cPropertySets, DBPROPSET rgPropertySets[], IUnknown **ppColRowset);
Parameters
For information about the properties in the Rowset property group that are defined by OLE DB, see "Rowset Properties" in Appendix C. For information about the DBPROPSET and DBPROP structures, see "DBPROPSET Structure" and "DBPROP Structure" in Chapter 14: Properties.
Return Code
DB_S_ASYNCHRONOUS should be returned before DB_S_ERRORSOCCURRED.
DB_S_ASYNCHRONOUS should be returned before DB_S_ERRORSOCCURRED. Once rowset population is complete, the consumer can see DB_S_ERRORSOCCURRED either by calling IDBAsynchStatus::GetStatus or by receiving IDBAsynchNotify::OnStop. Of course, the properties-in-error are not available, but for any properties that could not be set, the provider should report that status in the property array passed to IColumnsRowset::GetColumnsRowset (assuming that property failures can all be determined ahead of rowset population).
cPropertySets was greater than zero, and rgPropertySets was a null pointer.
In an element of rgPropertySets, cProperties was not zero and rgProperties was a null pointer.
cOptColumns was greater than zero, and rgOptColumns was a null pointer.
pUnkOuter was not a null pointer, and riid was not IID_IUnknown.
Comments
This method makes no logical change to the state of the object.
IColumnsRowset::GetColumnsRowset creates a rowset containing metadata about a rowset. Unlike IColumnsInfo::GetColumnInfo, it provides all of the metadata but it is more complex to implement and use.
The rows in the column metadata rowset describe the columns in the underlying rowset. The column metadata rowset contains one row for each column in the rowset. This includes the columns of the base table and any pseudo-columns generated by the provider or data source object, such as bookmarks and row IDs.
The order of the rows is the order in which the columns appear in the rowset (column ordinal order). This is the same order as they appear in IColumnsInfo. The order is usually predictable from the ordering of requested columns in the command text; if the command text does not specify an order, such as SELECT * FROM MyTable, the order is determined by the provider—for example, when the command is prepared.
Each column in the column metadata rowset describes a single attribute, such as the name or data type, of a column in the original rowset. The order of the required columns is the same as the order in which they are listed below. The order of the optional columns is arbitrary, although they must be after the required columns. That is, the optional columns in the column metadata rowset can occur in any order after the required columns.
The column metadata rowset always includes the required columns. It contains only those optional columns that are requested.
IColumnsRowset::GetColumnsRowset can be called for rowsets created by GetColumnsRowset.
Calling IColumnsRowset::GetColumnsRowset on a command before the command is executed may be an expensive operation.
The column metadata rowset always contains the following columns; these columns return the same information as IColumnsInfo::GetColumnInfo.
Column ID | Type indicator | Description |
---|---|---|
DBCOLUMN_IDNAME | DBTYPE_WSTR | Column name. This column, together with the DBCOLUMN_GUID and DBCOLUMN_PROPID columns, forms the ID of the column. One or more (but not all) of these columns will be NULL, depending on which elements of the DBID structure the provider uses.
The column ID of a base table should be invariant under views. |
DBCOLUMN_GUID | DBTYPE_GUID | Column GUID. |
DBCOLUMN_PROPID | DBTYPE_UI4 | Column property ID. |
DBCOLUMN_NAME | DBTYPE_WSTR | The name of the column; this might not be unique. If this cannot be determined, a NULL is returned.
The name can be different from the value returned in DBCOLUMN_IDNAME if the column has been renamed by the command text. This name always reflects the most recent renaming of the column in the current view or command text. If IColumnsRowset::GetColumnsRowset is called for a column metadata rowset (the rowset returned by GetColumnsRowset), the name of each column is the name of the column ID constant. For example, the name of the DBCOLUMN_SCALE column is "DBCOLUMN_SCALE". |
DBCOLUMN_NUMBER | DBTYPE_UI4 | The ordinal of the column. This is zero for the bookmark column of the row, if any. Other columns are numbered starting with one. This column cannot contain a NULL value. |
DBCOLUMN_TYPE | DBTYPE_UI2 | The indicator of the column's data type. If the data type of the column varies from row to row, this must be DBTYPE_VARIANT. This column cannot contain a NULL value. For a list of valid type indicators, see "Type Indicators" in Appendix A. |
DBCOLUMN_TYPEINFO | DBTYPE_IUNKNOWN | Reserved for future use. Providers should return a null pointer in pTypeInfo. |
DBCOLUMN_COLUMNSIZE | DBTYPE_UI4 | The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type. For columns that use a variable-length data type, this is one of the following:
For data types that do not have a length, this is set to ~0 (bitwise, the value is not 0; all bits are set to 1). |
DBCOLUMN_PRECISION | DBTYPE_UI2 | If DBCOLUMN_TYPE is a numeric data type, this is the maximum precision of the column. The precision of columns with a data type of DBTYPE_DECIMAL or DBTYPE_NUMERIC depends on the definition of the column. For the precision of all other numeric data types, see "Precision of Numeric Data Types" in Appendix A.
If DBCOLUMN_TYPE is not a numeric data type, this is NULL. |
DBCOLUMN_SCALE | DBTYPE_I2 | If DBCOLUMN_TYPE is DBTYPE_DECIMAL or DBTYPE_NUMERIC, this is the number of digits to the right of the decimal point. Otherwise, this is NULL. |
DBCOLUMN_FLAGS | DBTYPE_UI4 | A bitmask that describes column characteristics. The DBCOLUMNFLAGS enumerated type specifies the bits in the bitmask. For more information, see IColumnsInfo::GetColumnInfo. This column cannot contain a NULL value. |
The following columns are optional; if the column metadata rowset does not contain one of them, the consumer can safely use the default value. The default value is the value the consumer should assume if the provider does not support that information. It is also the value the column metadata rowset returns when the provider does have support but does not specify that information for a particular column. The provider can also have optional, provider-specific columns.
Column ID | Type indicator | Description |
---|---|---|
DBCOLUMN_BASECATALOGNAME | DBTYPE_WSTR | The name of the catalog in the data store that contains the column. NULL if the base catalog name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_BASECOLUMNNAME | DBTYPE_WSTR | The name of the column in the data store. This might be different than the column name returned in the DBCOLUMN_NAME column if an alias was used. NULL if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the data store.
The default of this column is NULL. |
DBCOLUMN_BASESCHEMANAME | DBTYPE_WSTR | The name of the schema in the data store that contains the column. NULL if the base schema name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_BASETABLENAME | DBTYPE_WSTR | The name of the table or view in the data store that contains the column. NULL if the base table name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_CLSID | DBTYPE_GUID | If all objects in the column all have the same class ID, this is that class ID. If the column may contain objects with different class IDs or if the column is not of DBTYPE_IUNKNOWN, this is set to NULL.
The default of this column is NULL. |
DBCOLUMN_COLLATINGSEQUENCE | DBTYPE_I4 | The locale ID (LCID) that defines the collating sequence for the column.
The default of this column is the code page installed on the local machine. |
DBCOLUMN_COMPUTEMODE | DBTYPE_I4 | Whether a column is computed. One of the following:
|
DBCOLUMN_DATETIMEPRECISION | DBTYPE_UI4 | The datetime precision—number of digits in the fractional seconds portion—if the column is a datetime or interval type.
The default of this column is derived from the value in column DATETIME_PRECISION in the COLUMNS schema rowset. |
DBCOLUMN_DEFAULTVALUE | DBTYPE_VARIANT | The column default value if declared statically. Dynamic initialization is handled by notifications. NULL if the default value cannot be determined. For a list of possible values, see COLUMN_DEFAULT in "COLUMNS Rowset" in Appendix B.
The default of this column is NULL. |
DBCOLUMN_DOMAINCATALOG | DBTYPE_WSTR | The name of the catalog containing the column's domain. NULL if the domain catalog name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_DOMAINSCHEMA | DBTYPE_WSTR | The name of the schema containing the column's domain. NULL if the domain schema name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_DOMAINNAME | DBTYPE_WSTR | The name of the domain of which the column is a member. NULL if the domain name cannot be determined.
The default of this column is NULL. |
DBCOLUMN_HASDEFAULT | DBTYPE_BOOL | VARIANT_TRUE: The column has a default value.
VARIANT_FALSE: The column does not have a default value. NULL: The provider could not determine whether the column has a default value or whether a default value does not make sense for the column. For example, it is a computed, derived, or nonupdatable column. The default of this column is VARIANT_FALSE. |
DBCOLUMN_ISAUTOINCREMENT | DBTYPE_BOOL | VARIANT_TRUE: The column assigns values to new rows in fixed increments.
VARIANT_FALSE: The column does not assign values to new rows in fixed increments. The default of this column is VARIANT_FALSE. |
DBCOLUMN_ISCASESENSITIVE | DBTYPE_BOOL | VARIANT_TRUE if the order of the column is case-sensitive and if searches on the column are case-sensitive. Otherwise, VARIANT_FALSE.
The default of this column is VARIANT_TRUE. |
DBCOLUMN_ISSEARCHABLE | DBTYPE_UI4 | An integer indicating the searchability of a column. For more information, see SEARCHABLE column in "PROVIDER_TYPES Rowset" in Appendix B.
The default of this column is derived from the value of the SEARCHABLE column in the PROVIDER_TYPES schema rowset. |
DBCOLUMN_ISUNIQUE | DBTYPE_BOOL | VARIANT_TRUE: No two rows in the base table—the table returned in DBCOLUMN_BASETABLENAME—can have the same value in this column. DBCOLUMN_ISUNIQUE is guaranteed to be VARIANT_TRUE if the column constitutes a key by itself or if there is a constraint of type UNIQUE that applies only to this column.
VARIANT_FALSE: The column can contain duplicate values in the base table. The default of this column is VARIANT_FALSE. |
DBCOLUMN_MAYSORT | DBTYPE_BOOL | VARIANT_TRUE: The column can be sorted.
VARIANT_FALSE: The column cannot be sorted. |
DBCOLUMN_OCTETLENGTH | DBTYPE_UI4 | The maximum length in octets (bytes) of the column, if the column is a character or binary type. A value of zero means the column has no maximum length. NULL for all other types of columns.
The default of this column is derived from the value of the CHARACTER_OCTET_LENGTH column in the COLUMNS schema rowset. |
DBCOLUMN_KEYCOLUMN | DBTYPE_BOOL | VARIANT_TRUE—The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with DBCOLUMN_KEYCOLUMN set to VARIANT_TRUE must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index.
VARIANT_FALSE—The column is not required to uniquely identify the row. |
DBCOLUMN_BASETABLEVERSION | DBTYPE_UI8 | Version number of the table in the data store that contains the column. This number is assumed to change every time the table definition is modified. The way in which this number is generated is provider specific. |
DBCOLUMN_DERIVEDCOLUMNNAME | DBTYPE_WSTR | The name of the column in the data store from which this rowset column is derived if, for example, derived from a single-column expression or an invertible function. Mutually exclusive with DBCOLUMN_BASECOLUMNNAME.
The default of this column is NULL. |
IColumnsInfo::GetColumnInfo | IColumnsRowset::GetAvailableColumns | IRowsetInfo::GetProperties