3
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5
<link rel="stylesheet" href="stylesheet.css" type="text/css">
6
<link rev="made" href="pgsql-docs@postgresql.org">
7
<meta name="generator" content="DocBook XSL Stylesheets V1.64.1">
8
<link rel="home" href="index.html" title="PostgreSQL 8.0.0beta5 Documentation">
9
<link rel="up" href="sql-commands.html" title="SQL Commands">
10
<link rel="previous" href="sql-end.html" title="END">
11
<link rel="next" href="sql-explain.html" title="EXPLAIN">
13
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
14
<a name="sql-execute"></a><div class="titlepage">
18
<div class="refnamediv">
20
<p>EXECUTE — execute a prepared statement</p>
22
<a name="id2686609"></a><a name="id2686618"></a><div class="refsynopsisdiv">
24
<pre class="synopsis">EXECUTE <i class="replaceable"><tt>plan_name</tt></i> [ (<i class="replaceable"><tt>parameter</tt></i> [, ...] ) ]</pre>
26
<div class="refsect1" lang="en">
27
<a name="id2686647"></a><h2>Description</h2>
28
<p> <tt class="command">EXECUTE</tt> is used to execute a previously prepared
29
statement. Since prepared statements only exist for the duration of a
30
session, the prepared statement must have been created by a
31
<tt class="command">PREPARE</tt> statement executed earlier in the
34
<p> If the <tt class="command">PREPARE</tt> statement that created the statement
35
specified some parameters, a compatible set of parameters must be
36
passed to the <tt class="command">EXECUTE</tt> statement, or else an
37
error is raised. Note that (unlike functions) prepared statements are
38
not overloaded based on the type or number of their parameters; the
39
name of a prepared statement must be unique within a database session.
41
<p> For more information on the creation and usage of prepared statements,
42
see <a href="sql-prepare.html">PREPARE</a>.
45
<div class="refsect1" lang="en">
46
<a name="id2686702"></a><h2>Parameters</h2>
47
<div class="variablelist"><dl>
48
<dt><span class="term"><i class="replaceable"><tt>plan_name</tt></i></span></dt>
49
<dd><p> The name of the prepared statement to execute.
51
<dt><span class="term"><i class="replaceable"><tt>parameter</tt></i></span></dt>
52
<dd><p> The actual value of a parameter to the prepared statement. This
53
must be an expression yielding a value of a type compatible with
54
the data type specified for this parameter position in the
55
<tt class="command">PREPARE</tt> command that created the prepared
60
<div class="refsect1" lang="en">
61
<a name="id2686738"></a><h2>Outputs</h2>
62
<p> The command tag returned by <tt class="command">EXECUTE</tt>
63
is that of the prepared statement, and not <tt class="literal">EXECUTE</tt>.
66
<div class="refsect1" lang="en">
67
<a name="id2686757"></a><h2>Examples</h2>
68
<p> Examples are given in the <a href="sql-prepare.html#sql-prepare-examples">Examples</a> section of the <a href="sql-prepare.html">PREPARE</a> documentation.
71
<div class="refsect1" lang="en">
72
<a name="id2686786"></a><h2>Compatibility</h2>
73
<p> The SQL standard includes an <tt class="command">EXECUTE</tt> statement,
74
but it is only for use in embedded SQL. This version of the
75
<tt class="command">EXECUTE</tt> statement also uses a somewhat different
79
<div class="refsect1" lang="en">
80
<a name="id2686806"></a><h2>See Also</h2>
81
<span class="simplelist"><a href="sql-deallocate.html">DEALLOCATE</a>, <a href="sql-prepare.html">PREPARE</a></span>