int mysql_next_result(MYSQL *mysql)
Description
This function is used when you execute multiple statements specified as a single statement string.
mysql_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.
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).
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.
If mysql_next_result()
returns
an error, no other statements are executed and there are no more
results to fetch.
It 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.
For an example that shows how to use
mysql_next_result()
, see
Section 17.6.12, “C API Support for Multiple Statement Execution”.
This function was added in MySQL 4.1.0.
Return Values
Return Value | Description |
0 | Successful and there are more results |
-1 | Successful and there are no more results |
>0 | An error occurred |
Errors
Commands were executed in an improper order. For example, if
you didn't call
mysql_use_result()
for a
previous result set.
The MySQL server has gone away.
The connection to the server was lost during the query.
An unknown error occurred.
User Comments
Add your own comment.