Views
Providers that do not support full command syntax can still expose simple operations such as sorting or filtering a rowset by applying a view. Views may be applied when opening a rowset, or they may be applied to an existing rowset in order to return either a new chapter on that rowset or a completely new rowset with the additional functionality.
Views are similar to commands, with the following restrictions:
-
The source of the rowset is a single table, fixed at the time the view is created.
-
Views support only simple operations such as filtering and sorting. They do not support complex semantics such as subqueries, joins, or dynamic parameters.
-
View operations are expressed through method calls as opposed to textual statements.
Views:
CoType TView {
[mandatory] interface IColumnsInfo;
[optional] interface IAccessor;
[optional] interface ISupportErrorInfo;
[optional] interface IViewChapter;
[optional] interface IViewFilter;
[optional] interface IViewRowset;
[optional] interface IViewSort;
};
Views are created in one of two ways:
-
Applying a view when opening a rowset. In order to apply a view when opening a rowset, the following steps occur:
-
The consumer requests that IID_IViewRowset be supported when executing a method that returns a rowset, either by setting the DBPROP_IViewRowset property, or by requesting IID_IViewRowset on the returned rowset. The method returns a view object in place of the rowset.
-
The consumer applies operations such as filtering and sorting to the view object through interfaces such as IViewFilter and IViewSort.
-
The consumer calls IViewRowset::OpenViewRowset on the view object in order to return the actual rowset.
-
Applying a view to an existing rowset. In order to apply a view to an existing rowset, the following steps occur:
-
The consumer calls IRowsetView::CreateView on the rowset.
-
The consumer applies operations such as filtering and sorting to the view object through interfaces such as IViewFilter and IViewSort.
-
The consumer calls IViewChapter::OpenViewChapter on the view to return a new chapter on the original rowset that reflects the view operations.
- or -
The consumer calls IViewRowset::OpenViewRowset on the view in order to return a new rowset with the view operations applied.