You are here : Cmysql/mysql.hmysql_next_result

mysql_next_result() - mysql/mysql.h

 This function is used when you execute multiple statements
        specified as a single statement string, or when you use
        CALL statements to execute stored
        procedures, which can return multiple result sets.CALLCALLmysql_next_result() reads the
        next statement result and returns a status to indicate whether
        more results exist. If
        mysql_next_result() returns an
        error, there are no more results.mysql_next_result()mysql_next_result()mysql_next_result()mysql_next_result()Before each call to
        mysql_next_result(), you must
        call mysql_free_result() for the
        current statement if it is a statement that returned a result
        set (rather than just a result status).mysql_next_result()mysql_next_result()mysql_free_result()mysql_free_result()After calling
        mysql_next_result() the state of
        the connection is as if you had called
        mysql_real_query() or
        mysql_query() for the next
        statement. This means that you can call
        mysql_store_result(),
        mysql_warning_count(),
        mysql_affected_rows(), and so
        forth.mysql_next_result()mysql_next_result()mysql_real_query()mysql_real_query()mysql_query()mysql_query()mysql_store_result()mysql_store_result()mysql_warning_count()mysql_warning_count()mysql_affected_rows()mysql_affected_rows()If your program uses CALL
        statements to execute stored procedures, the
        CLIENT_MULTI_RESULTS flag must be enabled.
        This is because each CALL returns
        a result to indicate the call status, in addition to any result
        sets that might be returned by statements executed within the
        procedure. Because CALL can
        return multiple results, process them using a loop that calls
        mysql_next_result() to determine
        whether there are more results.CALLCALLCLIENT_MULTI_RESULTSCALLCALLCALLCALLmysql_next_result()mysql_next_result()CLIENT_MULTI_RESULTS can be enabled when you
        call mysql_real_connect(),
        either explicitly by passing the
        CLIENT_MULTI_RESULTS flag itself, or
        implicitly by passing CLIENT_MULTI_STATEMENTS
        (which also enables CLIENT_MULTI_RESULTS). In
        MySQL 5.7, CLIENT_MULTI_RESULTS
        is enabled by default.CLIENT_MULTI_RESULTSmysql_real_connect()mysql_real_connect()CLIENT_MULTI_RESULTSCLIENT_MULTI_STATEMENTSCLIENT_MULTI_RESULTSCLIENT_MULTI_RESULTSIt is also possible to test whether there are more results by
        calling mysql_more_results().
        However, this function does not change the connection state, so
        if it returns true, you must still call
        mysql_next_result() to advance
        to the next result.mysql_more_results()mysql_more_results()mysql_next_result()mysql_next_result()For an example that shows how to use
        mysql_next_result(), see
        Section 25.8.17, “C API Support for Multiple Statement Execution”.mysql_next_result()mysql_next_result()Section 25.8.17, “C API Support for Multiple Statement Execution”


Syntax

int mysql_next_result(MYSQL *mysql)


Example

 


Output / Return Value

 Return ValueDescription0Successful and there are more results-1Successful and there are no more results>0An error occurredReturn ValueDescription0Successful and there are more results-1Successful and there are no more results>0An error occurredReturn ValueDescriptionReturn ValueDescriptionReturn ValueDescription0Successful and there are more results-1Successful and there are no more results>0An error occurred0Successful and there are more results0Successful and there are more results-1Successful and there are no more results-1Successful and there are no more results>0An error occurred>0An error occurred


Limitations


Alternatives / See Also


Reference