10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

28.4.4.3 The execute_prepared_stmt() Procedure

Given an SQL statement as a string, executes it as a prepared statement. The prepared statement is deallocated after execution, so it is not subject to reuse. Thus, this procedure is useful primarily for executing dynamic statements on a one-time basis.

This procedure usessys_execute_prepared_stmtas the prepared statement name. If that statement name exists when the procedure is called, its previous content is destroyed.

Parameters
  • in_query LONGTEXT CHARACTER SET utf8: The statement string to execute.

Configuration Options

execute_prepared_stmt()operation can be modified using the following configuration options or their corresponding user-defined variables (seeSection 28.4.2.1, “The sys_config Table”):

  • debug,@sys.debug

    If this option isON, produce debugging output. The default isOFF.

Example
mysql> CALL sys.execute_prepared_stmt('SELECT COUNT(*) FROM mysql.user'); +----------+ | COUNT(*) | +----------+ | 15 | +----------+