SQLNumParams - Get number of parameters in an SQL statement

Purpose

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

Syntax

SQLRETURN   SQLNumParams     (SQLHSTMT          StatementHandle,
                              SQLSMALLINT       *ParameterCountPtr);

Function arguments

Table 1. 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 that is 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() calls are necessary for the SQL statement associated with the statement handle.

Return codes

  • SQL_SUCCESS
  • SQL_SUCCESS_WITH_INFO
  • SQL_STILL_EXECUTING
  • SQL_ERROR
  • SQL_INVALID_HANDLE

Error conditions

Table 2. SQLNumParams SQLSTATEs
SQLSTATE Description Explanation
40003 08S01 Communication link failure The communication link between the application and data source fails before the function is completed.
HY001 Memory allocation failure DB2® UDB CLI is unable to allocate memory required to support the processing or completion of the function.
HY008 Operation canceled  
HY009 Argument value that is not valid ParameterCountPtr is null.
HY010 Function sequence error This function is called before SQLPrepare() is called for the specified StatementHandle

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

HY013 Unexpected memory handling error DB2 UDB CLI is unable to access memory required to support the processing or completion of the function.
HYT00 Timeout expired  

Restrictions

None.

Example

Refer to the SQLNativeSql() rzadpfnnsql.htm#rzadpfnnsql__xmnsql.

References