Call Level Interface Guide and Reference

SQLNumParams - Get Number of Parameters in A SQL Statement

Purpose


Specification: DB2 CLI 2.1 ODBC 1.0  

SQLNumParams() returns the number of parameter markers in an SQL statement.

Syntax

SQLRETURN   SQLNumParams     (SQLHSTMT          StatementHandle,
                              SQLSMALLINT  FAR  *ParameterCountPtr);

Function Arguments


Table 128. SQLNumParams Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle Input Statement handle.
SQLSMALLINT * ParameterCountPtr Output Number of parameters in the statement.

Usage

This function can only be called after the statement associated with StatementHandle has been prepared. If the statement does not contain any parameter markers, ParameterCountPtr is set to 0.

An application can call this function to determine how many SQLBindParameter() (or SQLBindFileToParam()) calls are necessary for the SQL statement associated with the statement handle.

Return Codes

Diagnostics


Table 129. SQLNumParams SQLSTATEs
SQLSTATE Description Explanation
40003 08S01 Communication link failure. The communication link between the application and data source failed before the function completed.
HY001 Memory allocation failure. DB2 CLI is unable to allocate memory required to support execution or completion of the function.
HY008 Operation canceled.

Asynchronous processing was enabled for the StatementHandle. The function was called and before it completed execution, SQLCancel() was called on the StatementHandle. Then the function was called again on the StatementHandle.

The function was called and, before it completed execution, SQLCancel() was called on the StatementHandle from a different thread in a multithread application.

HY010 Function sequence error. This function was called before SQLPrepare() was called for the specified StatementHandle

The function was called while in a data-at-execute (SQLParamData(), SQLPutData()) operation.

The function was called while within a BEGIN COMPOUND and END COMPOUND SQL operation.

HY013 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.
HYT00 Timeout expired. The timeout period expired before the data source returned the result set. Timeouts are only supported on non-multitasking systems such as Windows 3.1 and Macintosh System 7. The timeout period can be set using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetConnectAttr().

Restrictions

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 ]