Поделиться через


Bookmark Types (OLE DB)

OLE DB supports two kinds of bookmarks: numeric and key value. The DBPROP_BOOKMARKTYPE property indicates the bookmarks that a provider supports.

Numeric Bookmarks

Numeric bookmarks are based on a position or index into the rows selected for a rowset. In most cases, the rowset builds a set of information about the rows, which enables the same row to be retrieved easily. It does not guarantee the existence or consistency of those rows throughout the transaction; that still depends on the transaction isolation level. It returns the same row entity if it can.

The numeric value can be of any size. A small rowset might use a 16-bit index, whereas a rowset against an Oracle table might use Oracle ROWIDs, which are around 6 bytes each. There is no significance to the ordering of numeric values, either logical or physical. The implementation should simply be fast.

If the primary key value of a row is changed while working with a row for which the consumer has a numeric bookmark, the bookmark still points to the same row instance. This is required for a numeric bookmark. The row also has a nonoverlapping candidate key; the primary key may change entirely, but the same value remains in the candidate key column.

Key Value Bookmarks

When a rowset is ordered and there is some combination of columns (not necessarily the primary keys of the base tables) that form a unique key for each row, it becomes useful to use these values as a bookmark. At first it might seem redundant, because one could expect an interface such as IRowsetIndex to take key values and rapidly return a numeric bookmark. However, the numeric bookmark itself may be costly and unwanted. In some cases, the key values enable the provider to access the underlying tables without storing any kind of temporary table.

With a key value bookmark, a consumer could, in theory, synthesize a set of values that could occur but do not. The result of doing this is undefined; that is, providers are not required to detect forgeries.

If the key value columns of a row are changed while working with a row for which the consumer has a key value bookmark, the bookmark can become disassociated or point to a new row that usurps the old values.