SQLMoreResults - Determine whether there are more result sets
SQLMoreResults() determines whether there is more information available on the statement handle that has been associated with a stored procedure that is returning result sets.
Syntax
SQLRETURN SQLMoreResults (SQLHSTMT StatementHandle);
Function arguments
Table 1. SQLMoreResults arguments Data type Argument Use Description SQLHSTMT StatementHandle input Statement handle
Usage
This function is used to return multiple results that are set in a sequential manner upon the processing of a stored procedure that contains SQL queries. The cursors have been left open so that the result sets remain accessible when the stored procedure has finished processing.
After completely processing the first result set, the application can call SQLMoreResults() to determine if another result set is available. If the current result set has unfetched rows, SQLMoreResults() discards them by closing the cursor and, if another result set is available, returns SQL_SUCCESS.
If all the result sets have been processed, SQLMoreResults() returns SQL_NO_DATA_FOUND.
If SQLFreeStmt() is called with the SQL_CLOSE or SQL_DROP option, all pending result sets on this statement handle are discarded.
Return codes
- SQL_SUCCESS
- SQL_SUCCESS_WITH_INFO
- SQL_ERROR
- SQL_INVALID_HANDLE
- SQL_NO_DATA_FOUND
Error conditions
Table 2. SQLMoreResults SQLSTATEs SQLSTATE Description Explanation 40003 08S01 Communication link failure The communication link between the application and data source fails before the function is completed. 58004 Unexpected system failure Unrecoverable system error. HY001 Memory allocation failure DB2® UDB CLI is unable to allocate memory required to support the processing or completion of the function. HY010 Function sequence error 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. HY021 Internal descriptor that is not valid The internal descriptor cannot be addressed or allocated, or it contains a value that is not valid. HYT00 Timeout expired In addition SQLMoreResults() can return the SQLSTATEs associated with SQLExecute().
Restrictions
The ODBC specification of SQLMoreResults() also allow counts associated with the processing of parameterized INSERT, UPDATE, and DELETE statements with arrays of input parameter values to be returned. However, DB2 UDB CLI does not support the return of such count information.
References
- SQLBindCol - Bind a column to an application variable
- SQLBindParameter - Bind a parameter marker to a buffer
Parent topic:
DB2 UDB CLI functions