Skip to content

Latest commit

 

History

History
80 lines (64 loc) · 5.76 KB

sqlnumparams-function.md

File metadata and controls

80 lines (64 loc) · 5.76 KB
titledescriptionauthorms.authorms.datems.servicems.subservicems.topicf1_keywordshelpviewer_keywordsapilocationapinameapitype
SQLNumParams Function
SQLNumParams Function
David-Engel
davidengel
07/18/2019
sql
connectivity
reference
SQLNumParams
SQLNumParams function [ODBC]
sqlsrv32.dll
SQLNumParams
dllExport

SQLNumParams Function

Conformance
Version Introduced: ODBC 1.0 Standards Compliance: ISO 92

Summary
SQLNumParams returns the number of parameters in a SQL statement.

Syntax

 SQLRETURN SQLNumParams( SQLHSTMT StatementHandle, SQLSMALLINT * ParameterCountPtr); 

Arguments

StatementHandle
[Input] Statement handle.

ParameterCountPtr
[Output] Pointer to a buffer in which to return the number of parameters in the statement.

Returns

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.

Diagnostics

When SQLNumParams returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by SQLNumParams and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATEErrorDescription
01000General warningDriver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
08S01Communication link failureThe communication link between the driver and the data source to which the driver was connected failed before the function completed processing.
HY000General errorAn error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause.
HY001Memory allocation errorThe driver was unable to allocate memory required to support execution or completion of the function.
HY008Operation canceledAsynchronous processing was enabled for the StatementHandle. The SQLNumParams function was called and, before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle; the SQLNumParams function was then called again on the StatementHandle.

Or, the SQLNumParams function was called and, before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application.
HY010Function sequence error(DM) The function was called prior to calling SQLPrepare or SQLExecDirect for the StatementHandle.

(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. This asynchronous function was still executing when the SQLNumParams function was called.

(DM) An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called.

(DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns.
HY013Memory management errorThe function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
HY117Connection is suspended due to unknown transaction state. Only disconnect and read-only functions are allowed.(DM) For more information on suspended state, see SQLEndTran Function.
HYT01Connection timeout expiredThe connection timeout period expired before the data source responded to the request. The connection timeout period is set through SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
IM001Driver does not support this function(DM) The driver associated with the StatementHandle does not support the function.
IM017Polling is disabled in asynchronous notification modeWhenever the notification model is used, polling is disabled.
IM018SQLCompleteAsync has not been called to complete the previous asynchronous operation on this handle.If the previous function call on the handle returns SQL_STILL_EXECUTING and if notification mode is enabled, SQLCompleteAsync must be called on the handle to do post-processing and complete the operation.

Comments

SQLNumParams can be called only after SQLPrepare has been called.

If the statement associated with StatementHandle does not contain parameters, SQLNumParams sets *ParameterCountPtr to 0.

The number of parameters returned by SQLNumParams is the same value as the SQL_DESC_COUNT field of the IPD.

For more information, see Describing Parameters.

Related Functions

For information aboutSee
Binding a buffer to a parameterSQLBindParameter Function
Returning information about a parameter in a statementSQLDescribeParam Function

See Also

ODBC API Reference
ODBC Header Files

close