SQLNumParams function (CLI) - Get number of parameters in a SQL statement
Returns the number of parameter markers in an SQL statement.
Specification:
- CLI 2.1
- ODBC 1.0
Syntax
SQLRETURN SQLNumParams (
SQLHSTMT StatementHandle, /* hstmt */
SQLSMALLINT *ParameterCountPtr); /* pcpar */
Function arguments
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | Input | Statement handle. |
SQLSMALLINT * | ParameterCountPtr | Output | Number of parameters in the statement. |
Usage
If the prepared SQL statement associated with Statement Handle contains batch SQL (multiple SQL statements separated by a semicolon ';'), the parameters are counted for the entire string and are not differentiated by the individual statements making up the batch.
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
- SQL_SUCCESS
- SQL_SUCCESS_WITH_INFO
- SQL_STILL_EXECUTING
- SQL_ERROR
- SQL_INVALID_HANDLE
Diagnostics
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. It is likely that process-level memory has been exhausted for the application process. Consult the operating system configuration for information about process-level memory limitations. |
HY008 | Operation was Canceled. | Asynchronous processing was enabled for StatementHandle. The function was called and before it completed execution, SQLCancel() was called on StatementHandle from a different thread in a multithreaded application. Then the
function was called again on StatementHandle. |
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 ( 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. The timeout period
can be set using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetStmtAttr() .
Note: This SQLSTATE applies only to .Net applications.
|
Restrictions
None.