SQLNumResultCols function (CLI - Get number of result columns
Returns the number of columns in the result set associated with the input statement handle.
Specification:
- CLI 1.1
- ODBC 1.0
- ISO CLI
SQLPrepare() or SQLExecDirect() must be called before calling this function.
After calling this function, you can call SQLColAttribute(), or one of the bind column functions.
Syntax
SQLRETURN SQLNumResultCols (
SQLHSTMT StatementHandle, /* hstmt */
SQLSMALLINT *ColumnCountPtr); /* pccol */
Function arguments
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | input | Statement handle |
SQLSMALLINT * | ColumnCountPtr | output | Number of columns in the result set |
Usage
The function sets the output argument to zero if the last statement or function executed on the input statement handle did not generate a result set.
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. |
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. 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. | The function was called before calling SQLPrepare() or SQLExecDirect() for the 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. The timeout period
can be set using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetStmtAttr() .
Note: This SQLSTATE applies only to .Net applications.
|
Authorization
None.
Example
/* identify the number of output columns */
cliRC = SQLNumResultCols(hstmt, &nResultCols);