<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="sys-execute-prepared-stmt">
      </a>
      30.4.4.3 The execute_prepared_stmt() Procedure
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045061568256">
  </a>
  <a class="indexterm" name="idm46045061566752">
  </a>
  <p>
   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.
  </p>
  <p>
   This procedure uses
   <code class="literal">
    sys_execute_prepared_stmt
   </code>
   as the prepared
          statement name. If that statement name exists when the
          procedure is called, its previous content is destroyed.
  </p>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="sys-execute-prepared-stmt-parameters">
       </a>
       Parameters
      </h5>
     </div>
    </div>
   </div>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        in_query LONGTEXT CHARACTER SET
                utf8mb3
       </code>
       : The statement string to execute.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="sys-execute-prepared-stmt-configuration-options">
       </a>
       Configuration Options
      </h5>
     </div>
    </div>
   </div>
   <p>
    <a class="link" href="sys-execute-prepared-stmt.html" title="30.4.4.3 The execute_prepared_stmt() Procedure">
     <code class="literal">
      execute_prepared_stmt()
     </code>
    </a>
    operation can be modified using the following configuration
            options or their corresponding user-defined variables (see
    <a class="xref" href="sys-sys-config.html" title="30.4.2.1 The sys_config Table">
     Section 30.4.2.1, “The sys_config Table”
    </a>
    ):
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        debug
       </code>
       ,
       <code class="literal">
        @sys.debug
       </code>
      </p>
      <p>
       If this option is
       <code class="literal">
        ON
       </code>
       , produce
                debugging output. The default is
       <code class="literal">
        OFF
       </code>
       .
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h5 class="title">
       <a name="sys-execute-prepared-stmt-example">
       </a>
       Example
      </h5>
     </div>
    </div>
   </div>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40821756"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>execute_prepared_stmt<span class="token punctuation">(</span><span class="token string">'SELECT COUNT(*) FROM mysql.user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> COUNT(*) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>       15 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
