Call Level Interface Guide and Reference

SQLRowCount - Get Row Count

Purpose


Specification: DB2 CLI 1.1 ODBC 1.0 ISO CLI

SQLRowCount() returns the number of rows in a table that were affected by an UPDATE, INSERT, or DELETE statement executed against the table, or a view based on the table.

SQLExecute() or SQLExecDirect() must be called before calling this function.

Syntax

SQLRETURN   SQLRowCount      (SQLHSTMT          StatementHandle,   /* hstmt */
                              SQLINTEGER   FAR  *RowCountPtr);     /* pcrow */

Function Arguments

Table 146. SQLRowCount Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle input Statement handle
SQLINTEGER * RowCountPtr output Pointer to location where the number of rows affected is stored.

Usage

If the last executed statement referenced by the input statement handle was not an UPDATE, INSERT, or DELETE statement, or if it did not execute successfully, then the function sets the contents of RowCountPtr to -1.

Any rows in other tables that may have been affected by the statement (for example, cascading deletes) are not included in the count.

Return Codes

Diagnostics

Table 147. SQLRowCount SQLSTATEs
SQLSTATE Description Explanation
40003 08S01 Communication link failure. The communication link between the application and data source failed before the function completed.
58004 Unexpected system failure. Unrecoverable system error.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution or completion of the function.
HY010 Function sequence error. The function was called prior to calling SQLExecute() or SQLExecDirect() for the StatementHandle.
HY013 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.

Authorization

None.

Example

See the README file in the sqllib\samples\cli (or sqllib/samples/cli) subdirectory for a list of appropriate samples.

References


[ Top of Page | Previous Page | Next Page ]