Overview of Commands

In OLE DB, Data Definition Language (DDL) and Data Manipulation Language (DML) statements are referred to as text commands. A command object contains a text command and its main purpose is to execute the command. Commands expose various interfaces representing different areas of functionality of a query processor, including query formulation, preparation, and execution. Text commands are expressed in a provider-specific language—usually ANSI SQL92. Commands can be in one of four states: Initial, Unprepared, Prepared, or Executed. Parameters can be used with commands to bind to consumer variables at execution time. When executed, commands return results: either a rowset or a row count, or multiple results. This chapter discusses the use and states of command objects, binding input parameters and determining support of output parameters, and the results set.

For more information on Go to
Using commands "Using Commands" in this chapter
Command states "Command States" in this chapter
Input and Output Parameters "Using Parameters" in this chapter
Multiple results "Multiple Results" in this chapter

A command is used to execute a provider-specific text command, such as an SQL statement. It is important not to confuse a command, which is an object, and its command text, which is a string. Commands are usually used for data definition, such as creating a table or granting privileges, and data manipulation, such as updating or deleting rows. A special case of data manipulation is creating a rowset—for example, an SQL SELECT statement.

Providers are not required to support commands. In general, providers built on top of a DBMS, such as an SQL DBMS, support commands, and providers built on top of a simple data structure, such as a file or an array of data in an application, do not support commands.

Command objects:

CoType TCommand {
   [mandatory] interface IAccessor;
   [mandatory] interface IColumnsInfo;
   [mandatory] interface ICommand;
   [mandatory] interface ICommandProperties;
   [mandatory] interface ICommandText;
   [mandatory] interface IConvertType;
   [optional]  interface IColumnsRowset;
   [optional]  interface ICommandPrepare;
   [optional]  interface ICommandWithParameters;
   [optional]  interface ISupportErrorInfo;
}