• User variable settings are lost.
• Prepared statements are released.
•
HANDLER
• The value of
• Locks acquired with
If the connection drops, it is possible that the session associated with the connection on the server side
will still be running if the server has not yet detected that the client is no longer connected. In this case,
any locks held by the original connection still belong to that session, so you may want to kill it by calling
mysql_kill().
20.6.15. C API Support for Multiple Statement Execution
By default,
mysql_query()
as a single statement to be executed, and you process the result according to whether the statement
produces a result set (a set of rows, as for SELECT) or an affected-rows count (as for INSERT,
UPDATE, and so forth).
MySQL 5.0 also supports the execution of a string containing multiple statements separated by
semicolon (";") characters. This capability is enabled by special options that are specified either
when you connect to the server with
mysql_set_server_option().
Executing a multiple-statement string can produce multiple result sets or row-count indicators.
Processing these results involves a different approach than for the single-statement case: After
handling the result from the first statement, it is necessary to check whether more results exist
and process them in turn if so. To support multiple-result processing, the C API includes the
mysql_more_results()
end of a loop that iterates as long as more results are available. Failure to process the result this way
may result in a dropped connection to the server.
Multiple-result processing also is required if you execute
Results from a stored procedure have these characteristics:
• Statements within the procedure may produce result sets (for example, if it executes
statements). These result sets are returned in the order that they are produced as the procedure
executes.
In general, the caller cannot know how many result sets a procedure will return. Procedure execution
may depend on loops or conditional statements that cause the execution path to differ from one call
to the next. Therefore, you must be prepared to retrieve multiple results.
• The final result from the procedure is a status result that includes no result set. The status indicates
whether the procedure succeeded or an error occurred.
The multiple statement and result capabilities can be used only with
mysql_real_query(). They cannot be used with the prepared statement interface. Prepared
statement handles are defined to work only with strings that contain a single statement. See
Section 20.6.7, "C API Prepared
To enable multiple-statement execution and result processing, the following options may be used:
• The
mysql_real_connect()
relevant:
•
CLIENT_MULTI_RESULTS
must be enabled if you execute
C API Support for Multiple Statement Execution
variables are closed.
LAST_INSERT_ID()
GET_LOCK()
and
mysql_real_query()
and
mysql_next_result()
Statements".
function has a
enables the client program to process multiple results. This option
[961]
is reset to 0.
[965]
are released.
mysql_real_connect()
functions. These functions are used at the
CALL
argument for which two option values are
flags
statements for stored procedures that produce result sets.
CALL
2226
interpret their statement string argument
or after connecting by calling`
statements for stored procedures.
mysql_query()
SELECT
or
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers