summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/sql-execute.html
blob: 0becaecbf93a28ed347355e4480146e8c786bf8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>EXECUTE</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-end.html" title="END" /><link rel="next" href="sql-explain.html" title="EXPLAIN" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">EXECUTE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-end.html" title="END">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-explain.html" title="EXPLAIN">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-EXECUTE"><div class="titlepage"></div><a id="id-1.9.3.147.1" class="indexterm"></a><a id="id-1.9.3.147.2" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">EXECUTE</span></h2><p>EXECUTE — execute a prepared statement</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
EXECUTE <em class="replaceable"><code>name</code></em> [ ( <em class="replaceable"><code>parameter</code></em> [, ...] ) ]
</pre></div><div class="refsect1" id="id-1.9.3.147.6"><h2>Description</h2><p>
   <code class="command">EXECUTE</code> is used to execute a previously prepared
   statement. Since prepared statements only exist for the duration of a
   session, the prepared statement must have been created by a
   <code class="command">PREPARE</code> statement executed earlier in the
   current session.
  </p><p>
   If the <code class="command">PREPARE</code> statement that created the statement
   specified some parameters, a compatible set of parameters must be
   passed to the <code class="command">EXECUTE</code> statement, or else an
   error is raised. Note that (unlike functions) prepared statements are
   not overloaded based on the type or number of their parameters; the
   name of a prepared statement must be unique within a database session.
  </p><p>
   For more information on the creation and usage of prepared statements,
   see <a class="xref" href="sql-prepare.html" title="PREPARE"><span class="refentrytitle">PREPARE</span></a>.
  </p></div><div class="refsect1" id="id-1.9.3.147.7"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
      The name of the prepared statement to execute.
     </p></dd><dt><span class="term"><em class="replaceable"><code>parameter</code></em></span></dt><dd><p>
      The actual value of a parameter to the prepared statement.  This
      must be an expression yielding a value that is compatible with
      the data type of this parameter, as was determined when the
      prepared statement was created.
     </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.147.8"><h2>Outputs</h2><p>
   The command tag returned by <code class="command">EXECUTE</code>
   is that of the prepared statement, and not <code class="literal">EXECUTE</code>.
  </p></div><div class="refsect1" id="id-1.9.3.147.9"><h2>Examples</h2><p>
    Examples are given in <a class="xref" href="sql-prepare.html#SQL-PREPARE-EXAMPLES" title="Examples">Examples</a>
    in the <a class="xref" href="sql-prepare.html" title="PREPARE"><span class="refentrytitle">PREPARE</span></a> documentation.
   </p></div><div class="refsect1" id="id-1.9.3.147.10"><h2>Compatibility</h2><p>
   The SQL standard includes an <code class="command">EXECUTE</code> statement,
   but it is only for use in embedded SQL.  This version of the
   <code class="command">EXECUTE</code> statement also uses a somewhat different
   syntax.
  </p></div><div class="refsect1" id="id-1.9.3.147.11"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-deallocate.html" title="DEALLOCATE"><span class="refentrytitle">DEALLOCATE</span></a>, <a class="xref" href="sql-prepare.html" title="PREPARE"><span class="refentrytitle">PREPARE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-end.html" title="END">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-explain.html" title="EXPLAIN">Next</a></td></tr><tr><td width="40%" align="left" valign="top">END </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="40%" align="right" valign="top"> EXPLAIN</td></tr></table></div></body></html>