Rechercher dans le manuel MySQL
28.7.7.47 mysql_next_result()
int mysql_next_result(MYSQL *mysql)
Description
mysql_next_result()
is a
synchronous function. Its asynchronous counterpart is
mysql_next_result_nonblocking()
,
for use by applications that require asynchronous
communication with the server. See
Section 28.7.12, “C API Asynchronous Interface”.
mysql_next_result()
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.
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 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.
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
).
CLIENT_MULTI_RESULTS
is enabled by default.
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 28.7.23, “C API Multiple Statement Execution Support”.
Return Value | Description |
---|---|
0 | Successful and there are more results |
-1 | Successful and there are no more results |
>0 | An error occurred |
Commands were executed in an improper order. For example, if you did not 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.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-mysql-next-result.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.