Home How To Online Documentation Support Download Order





Enums and Typedefs

Class Members


SACommand object

A SACommand object defines a specific command that you intend to execute against a data source.

A SACommand object may be used to query a database and return records, insert or update data, to manipulate the structure of a database, or to run a stored procedure.

With the methods of a SACommand object you can do the following:

  • Associate an opened connection with a SACommand object by using its setConnection method.

  • Define the executable text of the command (for example, a SELECT statement or a stored procedure name) and the command type with the setCommandText method.

  • Bind query input variables assigning SAParam object(s) returning by Param and ParamByIndex methods, or bind input variables using stream operator <<.

  • Execute a command using Execute method.

  • Check whether a result set exists using isResultSet method, and fetch row by row from it with the FetchNext method. Get SAField objects with Field method and access their descriptions and values.

  • Receive output variables and access their values using Param and ParamByIndex methods.

You can construct command based on the given connection, or with no associated SAConnection object using appropriate SACommand constructor. If you create new command with no connection, you need to use setConnection method before executing any other SACommand methods.

To set command text use setCommandText method. If the command has parameters, a set of SAParam objects creates implicitly. You can get the number of parameters with ParamCount method and look them through (and assign) with Param and ParamByIndex methods. Values for the input parameters can also be supplied by operator <<.

To prepare a command use Prepare method. If you will not prepare a command it will be prepared implicitly before execution. If needed a command will be implicitly opened. If, for some reason, you want to open a command explicitly use Open method. To execute a command use Execute method. A command will be implicitly closed in destructor. If, for some reason, you want to close a command explicitly use Close method. To test whether a command is opened use isOpened method.

A command (an SQL statement or procedure) can have a result set after executing. To check whether a result set exists use isResultSet method. If result set exists, a set of SAField objects created implicitly. SAField object contains full information about a field (name, type, size, etc.) and a field's value after fetching a row (FetchNext method). You can get the number of fields with FieldCount method and look them through with Field method or operator [] .

If command has output parameters, you can get them after a command execution using Param and ParamByIndex methods.

Problems and Questions

If you haven't found the answer to your questions or have some problems on using the Library, please, send e-mail to howto@sqlapi.com.