OLE DB Programmer's Reference |
Deletes one or more named columns from a row. For row-specific columns of a row that is in immediate update mode, this is an immediate schema operation.
HRESULT DeleteColumns( DBORDINAL cColumns, const DBID rgColumnIDs[ ], DBSTATUS rgdwStatus[ ] );
Parameters
Status field | Description |
---|---|
DBSTATUS_S_OK | Indicates that the column value was deleted. |
DBROWSTATUS_S_ROWSETCOLUMN | Providers may return this status flag when asked to delete a rowset column from a row. The value is actually nulled, but the column remains in the row and rowset. |
DBSTATUS_E_DOESNOTEXIST | Indicates that the column does not exist on this row. |
DBSTATUS_E_PERMISSIONDENIED | The consumer did not have sufficient permission to delete the column. |
The order of status elements must match the order of the column names in rgColumnIDs.
For more information, see "Status" in Chapter 6: Getting and Setting Data.
Return Code
Comments
IRowSchemaChange::DeleteColumns deletes the columns named in the rgColumnIDs array from the row. The behavior when deleted columns also belong to a source rowset or when the row is in deferred update mode is described below. If one or more of the named columns do not exist, the provider should set the corresponding element(s) of rgdwStatus to a DBSTATUS of DBSTATUS_E_DOESNOTEXIST and return DB_S_ERRORSOCCURRED or DB_E_ERRORSOCCURRED as appropriate.
If a row column also belongs to the row's source rowset or if the row is in deferred update mode, IRowSchemaChange::DeleteColumns is semantically equivalent to setting the column value to null. Subsequent attempts to retrieve the column, either using an accessor on the source rowset or using IRow::GetColumns, will return the null value. Furthermore, subsequent calls to IColumnsInfo on the containing rowset (if any) or to IColumnsInfo2::GetRestrictedColumnInfo will return metadata information for this column. The provider may elect to delete a row-specific column from the row once the source rowset and row have been released and re-instantiated. If a rowset column is non-nullable, IRowSchemaChange::DeleteColumns cannot set it to null. Instead, the provider should return DBSTATUS_E_INTEGRITYVIOLATION. If the column is typed as DBTYPE_VARIANT, the provider sets the column value to VT_EMPTY.
If a row column does not belong to the row's source rowset and the row is in immediate mode, or if there is no source rowset for the row, IRowSchemaChange::DeleteColumns removes the column from the row. Subsequent attempts to retrieve the column using IRow::GetColumns or to set the column using IRowChange::SetColumns or IRowSchemaChange::AddColumns will return an error and set the corresponding status value to DBSTATUS_E_DOESNOTEXIST. Furthermore, subsequent calls to IColumnsInfo2::GetRestrictedColumnInfo will not return metadata information for this column.
IRowSchemaChange::AddColumns or IRowChange::SetColumns can also be used to set column values to null.
1998-2001 Microsoft Corporation. All rights reserved.