Call Level Interface Guide and Reference

SQLMoreResults - Determine If There Are More Result Sets

Purpose


Specification: DB2 CLI 2.1 ODBC 1.0  

SQLMoreResults() determines whether there is more information available on the statement handle which has been associated with:

Syntax

SQLRETURN   SQLMoreResults   (SQLHSTMT          StatementHandle);  /* hstmt */

Function Arguments


Table 124. SQLMoreResults Arguments
Data Type Argument Use Description
SQLHSTMT StatementHandle input Statement handle.

Usage

This function is used to return multiple results set in a sequential manner upon the execution of:

Refer to Using Arrays to Input Parameter Values and Returning Result Sets from Stored Procedures for more information.

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 option, or SQLFreeHandle() is called with HandleType set to SQL_HANDLE_STMT, all pending result sets on this statement handle are discarded.

Return Codes

Diagnostics


Table 125. SQLMoreResults SQLSTATEs
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.
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. Timeouts are only supported on non-multitasking systems such as Windows 3.1 and Macintosh System 7. The timeout period can be set using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetConnectAttr().

In addition SQLMoreResults() can return the SQLSTATEs associated with SQLExecute().

Restrictions

The ODBC specification of SQLMoreResults() also allow counts associated with the execution of parameterized INSERT, UPDATE, and DELETE statements with arrays of input parameter values to be returned. However, DB2 CLI does not support the return of such count information.

CLI Sample pcall.c

(The complete sample pcall.c is also available here .)

 
/* From the CLI sample PCALL.C */
/* ... */
 
    /* print result sets, if any */
    do    
    {   rc = StmtResultPrint( hstmt1);
    }	    
    while( SQLMoreResults( hstmt1) == SQL_SUCCESS);   
    
 

References


[ Top of Page | Previous Page | Next Page ]