UPDATE and DELETE Statements
The following conditions must be satisfied for a remote table to be updated or deleted from a SQL Server distributed query:
- The provider must support bookmarks for the rowset opened through IOpenRowset on the table being updated or deleted.
- The provider must support the IRowsetLocate and IRowsetChange interfaces on the rowset opened through IOpenRowset for the table being updated or deleted.
- The IRowsetChange interface must support update (SetData) and delete (DeleteRows) methods.
- If the provider does not support ITransactionLocal, UPDATE/DELETE statements are allowed only if the Non-transacted option is set for that provider and if the statement is not in a user transaction.
- If the provider does not support ITransactionJoin, an UPDATE/DELETE statement is allowed only if it is not in a user transaction.
The following rowset properties are required on the rowset opened against the updated table: DBPROP_IRowsetLocate, DBPROP_IRowsetChange, and DBPROP_BOOKMARKS. The DBPROP_UPDATABILITY rowset property is set to DBPROPVAL_UP_CHANGE or DBPROPVAL_UP_DELETE depending on whether the operation performed is an UPDATE or a DELETE, respectively.
The following high-level steps against the provider for processing an UPDATE or DELETE operation are performed:
- SQL Server opens the base table rowset through the IOpenRowset interface. SQL Server requires the above-mentioned properties on the rowset.
- SQL Server determines the set of qualifying rows to be updated or deleted.
- SQL Server uses the bookmarks to position on the qualifying rows through the IRowsetLocate interface.
- Use IRowsetChange::SetData for UPDATE operations or IRowsetChange::DeleteRows for delete operations to perform the required changes on the qualifying rows.