Determines whether there is more information available on the statement handle which has been associated with: an array input of parameter values for a query; a stored procedure that is returning result sets; or, batched SQL.
SQLRETURN SQLMoreResults (SQLHSTMT StatementHandle); /* hstmt */
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | input | Statement handle. |
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.
Applications that want to be able to manipulate more than one result set at the same time can use the CLI function SQLNextResult() to move a result set to another statement handle. SQLNextResult() does not support batched statements.
When using batched SQL, SQLExecute() or SQLExecDirect() will only execute the first SQL statement in the batch. SQLMoreResults() can then be called to execute the next SQL statement and will return SQL_SUCCESS if the next statement is successfully executed. If there are no more statements to be executed, then SQL_NO_DATA_FOUND is returned. If the batched SQL statement is an UPDATE, INSERT, or DELETE statement, then SQLRowCount() can be called to determine the number of rows affected.
If SQLCloseCursor() or if SQLFreeStmt() is called with the SQL_CLOSE option, or SQLFreeHandle() is called with HandleType set to SQL_HANDLE_STMT, all pending result sets on this statement handle are discarded.
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. |
HY010 | Function sequence error. | 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(). |
In addition SQLMoreResults() can return the SQLSTATEs associated with SQLExecute().
cliRC = SQLMoreResults(hstmt);