Conformance
Version Introduced: ODBC 1.0
Standards Compliance: ISO 92
Summary
f90SQLRowCount returns the number of rows affected by an UPDATE, INSERT, or DELETE statement, an SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK operation in f90SQLBulkOperations, or an SQL_UPDATE or SQL_DELETE operation in f90SQLSetPos.
Syntax
| f90SQLRowCount | (StatementHandle, RowCount, iRet) |
| integer(SQLHSTMT_KIND),intent(in):: | StatementHandle |
| integer(SQLINTEGER_KIND),intent(out):: | RowCount |
| integer(SQLRETURN_KIND),intent(out):: | iRet |
Arguments
StatementHandle [Input]
Statement handle.
RowCount [Output]
Buffer in which to return a row count. For UPDATE, INSERT, and DELETE statements, for the SQL_ADD, SQL_UPDATE_BY_BOOKMARK, and SQL_DELETE_BY_BOOKMARK operations in f90SQLBulkOperations, and for the SQL_UPDATE or SQL_DELETE operations in f90SQLSetPos, the value returned in RowCount is the number of rows affected by the request or -1 if the number of affected rows is not available.
When f90SQLExecute, f90SQLExecDirect, f90SQLBulkOperations, f90SQLSetPos, or f90SQLMoreResults is called, the SQL_DIAG_ROW_COUNT field of the diagnostic data structure is set to the row count, and the row count is cached in an implementation-dependent way. f90SQLRowCount returns the cached row count value. The cached row count value is valid until the statement handle is set back to the prepared or allocated state, the statement is reexecuted, or f90SQLCloseCursor is called. Note that if a function has been called since the SQL_DIAG_ROW_COUNT field was set, the value returned by f90SQLRowCount might be different from the value in the SQL_DIAG_ROW_COUNT field, because the SQL_DIAG_ROW_COUNT field is reset to 0 by any function call.
For other statements and functions, the driver may define the value returned in RowCount. For example, some data sources may be able to return the number of rows returned by a SELECT statement or a catalog function before fetching the rows.
Note: Many data sources cannot return the number of rows in a result set before fetching them; for maximum interoperability, applications should not rely on this behavior.
iRet [Output]
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.
Diagnostics
When f90SQLRowCount returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling f90SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by f90SQLRowCount and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.
| SQLSTATE | Error | Description |
| 01000 | General warning | Driver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.) |
| HY000 | General error | An error occurred for which there was no
specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by f90SQLGetDiagRec in the MessageText buffer describes the error and its cause. |
| HY001 | Memory allocation error | The driver was unable to allocate memory required to support execution or completion of the function. |
| HY010 | Function sequence error | (DM) The function was called prior to calling f90SQLExecute, f90SQLExecDirect,
f90SQLBulkOperations, or f90SQLSetPos
for the StatementHandle. (DM) An asynchronously executing function was called for the StatementHandle and was still executing when this function was called. (DM) f90SQLExecute, f90SQLExecDirect, f90SQLBulkOperations, or f90SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns. |
| HY013 | Memory management error | The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions. |
| HYT01 | Connection timeout expired | The connection timeout period expired before the data source responded to the request. The connection timeout period is set through f90SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT. |
| IM001 | Driver does not support this function | (DM) The driver associated with the StatementHandle does not support the function. |
Comments
If the last SQL statement executed on the statement handle was not an UPDATE, INSERT, or DELETE statement, or the Operation argument in the previous call to f90SQLBulkOperations was not SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK, or the Operation argument in the previous call to f90SQLSetPos was not SQL_UPDATE or SQL_DELETE, the value of RowCount is driver-defined.
Related Subroutines
| For information about | See |
| Executing an SQL statement | f90SQLExecDirect |
| Executing a prepared SQL statement | f90SQLExecute |