次の方法で共有


Creating a Rowset with IOpenRowset (OLE DB)

Some providers need to expose very simple rowsets to their consumers. Conceptually, these rowsets represent the result of the simple query SELECT * FROM Tablename. To allow providers to interpret this simple query without the overhead of supporting a complete query language, OLE DB provides a simple rowset interface, IOpenRowset. IOpenRowset effectively exposes a rowset in the absence of a command. IOpenRowset is implemented on the session as shown in the following illustration.

Creating a rowset directly with IOpenRowset

Creating a rowset directly with IOpenRowset

Fully Qualified Names

A consumer may need to construct a fully qualified table name incorporating the names of the associated schema and catalog.

To construct a fully qualified name if DBPROP_CATALOGLOCATION is DBPROPVAL_CL_START or the provider does not support the DBPROP_CATALOGLOCATION property, a consumer follows these steps:

  1. If DBLITERAL_CATALOG_NAME is not NULL and not an empty string (fSupported is TRUE in DBLITERALINFO), get the appropriate catalog name for the table (for example, from the TABLES schema rowset) and append the value of DBLITERAL_CATALOG_SEPARATOR (pwszLiteralValue in DBLITERALINFO).

  2. If DBLITERAL_SCHEMA_NAME is not NULL (fSupported is TRUE in DBLITERALINFO), get the appropriate schema name for the table (for example, from the TABLES schema rowset) and append the value of DBLITERAL_SCHEMA_SEPARATOR (pwszLiteralValue in DBLITERALINFO). Append this to the catalog information from the previous step.

  3. Append the object (table) name.

To construct a fully qualified name if DBPROP_CATALOGLOCATION is DBPROPVAL_CL_END, a consumer follows these steps:

  1. If DBLITERAL_SCHEMA_NAME is not NULL and not an empty string (fSupported is TRUE in DBLITERALINFO), get the appropriate schema name for the table (for example, from the TABLES schema rowset) and append the value of DBLITERAL_SCHEMA_SEPARATOR (pwszLiteralValue in DBLITERALINFO).

  2. Append the object (table) name.

  3. If DBLITERAL_CATALOG_NAME is not NULL (fSupported is TRUE in DBLITERALINFO), append the value of DBLITERAL_CATALOG_SEPARATOR (pwszLiteralValue in DBLITERALINFO) and the appropriate catalog name for the table (for example, from the TABLES schema rowset).

Note

Consumers should provide qualified table names only to reference tables in other schemas or catalogs. Further, consumers should not quote table names unless such quoting is required to make table names unambiguous (such as, to enforce case sensitivity). Providers for which quoting a simple table name has no meaning might not support quoting tables in IOpenRowset::OpenRowset while they do support quoting tables as part of a command text for parsing reasons. Providers should not require table names to be quoted and should guarantee that unquoted table names correctly open the specified table, even if the table name contains special characters, as long as the table can be unambiguously identified without quoting.