SQLRowCount
SQLRowCount#
SQLRowCount returns the number of rows affected by an UPDATE, DELETE,or INSERT statement.
Syntax#
SQLRETURN SQLRowCount (
SQLHSTMT stmt,
SQLLEN * row );
Arguments#
Data Type | Argument | In/Output | Description |
---|---|---|---|
SQLHSTMT | stmt | Input | Statement handle |
SQLLEN * | row | Output | Pointer to save the number of row |
Return Values#
SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR
Description#
This function returns the number of rows affected by an UPDATE, INSERT or DELETE statement. For SQL statements which alter rows, such as MOVE, ENQUEUE and MERGE, the number of affected rows is returned in *row; if no rows are affected, 0 is returned.
If the SQL statement which was most recently executed by the input statement handle is not one listed above, or it failed to execute successfully, this function returns -1 in *row.
The rows in the tables affected by the SQL statement such as cascading delete operationare not included.
Before this funciton is called, SQLExecute() or SQLExecDirect() must be called.
Diagnosis#
SQLSTATE | Description | Comments |
---|---|---|
HY000 | General error |
Related Functions#
SQLExecDirect
SQLExecute
Example#
< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_exa5.cpp >
if (SQLExecute(stmt) != SQL_SUCCESS)
{
execute_err(dbc, stmt, query);
SQLFreeStmt(stmt, SQL_DROP);
return SQL_ERROR;
}
SQLRowCount(stmt, &row_count);