Comparing ct_resultsresult_type to DB-Library program logic

In Client-Library, ct_results takes a pointer argument to a result_type indicator. In addition to indicating command status (CS_CMD_SUCCEED and CS_CMD_FAIL), result_type indicates whether results are available and what type of results they represent.

Table 5-9 lists the possible values of result_type and compares them to the equivalent DB-Library program logic. For more information on these values, see the ct_results reference page in the Open Client Client-Library/C Reference Manual:

Table 5-9: ct_results’ result_type parameter vs. DB-Library program logic

Client-Library result_type

Indicates

DB-Library program logic

CS_CMD_DONE

The results of a logical command have been completely processed.

None. The receipt of CS_CMD_DONE by the Client-Library program is equivalent to the end of one iteration of the DB-Library dbresults loop.

CS_CMD_FAIL

The server encountered an error while executing a command.

Active routine (dbsqlexec, dbsqlok, or dbresults) returns FAIL.

CS_CMD_SUCCEED

The success of a command that returns no data, such as a language command containing a Transact-SQL insert statement.

dbresults returns SUCCEED. DBCMDROW returns FAIL to indicate that the command could not return rows.

CS_COMPUTE_RESULT

Compute row results.

Calls DBROWS to determine if rows are returned. There is no equivalent call or macro for DBROWS in Client-Library.

Calls dbnumcompute to determine if compute rows will be returned.

In the dbnextrow loop, dbnextrow returns > 0 when a compute row is retrieved.

CS_PARAM_RESULT

Return parameter results.

After dbnextrow returns NO_MORE_ROWS, checks whether dbnumrets returns > 0.

CS_ROW_RESULT

Regular row results.

DBCMDROW returns TRUE if the current command can return rows.

dbnextrow returns REG_ROW after each regular row is retrieved.

CS_STATUS_RESULT

Stored procedure return status results.

After dbnextrow returns NO_MORE_ROWS, checks if dbhasretstat returns TRUE.

CS_CURSOR_RESULT

Cursor row results.

None. DB-Library does not support server-based cursors.

CS_COMPUTEFMT_RESULT

  • Compute row format information.

  • Format results are seen only when the CS_EXPOSE_FORMATS property is enabled.

None.

CS_ROWFMT_RESULT

  • Regular row format information.

  • Format results are seen only when the CS_EXPOSE_FORMATS property is enabled.

None.

CS_MSG_RESULT

Arrival of a Client-Library message result set.

None. DB-Library does not support message commands and results.

CS_DESCRIBE_RESULT

Dynamic SQL descriptive information.

None. DB-Library does not support dynamic SQL.