2002-08-27 06:55:12 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/execute.sgml
|
2002-08-27 06:55:12 +02:00
|
|
|
PostgreSQL documentation
|
|
|
|
-->
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refentry id="sql-execute">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="sql-execute">
|
|
|
|
<primary>EXECUTE</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
|
|
|
<indexterm zone="sql-execute">
|
|
|
|
<primary>prepared statements</primary>
|
|
|
|
<secondary>executing</secondary>
|
|
|
|
</indexterm>
|
|
|
|
|
2002-08-27 06:55:12 +02:00
|
|
|
<refmeta>
|
2010-04-03 09:23:02 +02:00
|
|
|
<refentrytitle>EXECUTE</refentrytitle>
|
2008-11-14 11:22:48 +01:00
|
|
|
<manvolnum>7</manvolnum>
|
2002-08-27 06:55:12 +02:00
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
</refmeta>
|
2003-04-27 01:56:51 +02:00
|
|
|
|
2002-08-27 06:55:12 +02:00
|
|
|
<refnamediv>
|
2003-04-27 01:56:51 +02:00
|
|
|
<refname>EXECUTE</refname>
|
|
|
|
<refpurpose>execute a prepared statement</refpurpose>
|
2002-08-27 06:55:12 +02:00
|
|
|
</refnamediv>
|
2003-01-19 01:13:31 +01:00
|
|
|
|
2003-04-27 01:56:51 +02:00
|
|
|
<refsynopsisdiv>
|
|
|
|
<synopsis>
|
2017-10-09 04:00:57 +02:00
|
|
|
EXECUTE <replaceable class="parameter">name</replaceable> [ ( <replaceable class="parameter">parameter</replaceable> [, ...] ) ]
|
2003-04-27 01:56:51 +02:00
|
|
|
</synopsis>
|
2002-08-27 06:55:12 +02:00
|
|
|
</refsynopsisdiv>
|
|
|
|
|
2003-04-27 01:56:51 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
2002-08-27 06:55:12 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
<command>EXECUTE</command> is used to execute a previously prepared
|
2003-04-27 01:56:51 +02:00
|
|
|
statement. Since prepared statements only exist for the duration of a
|
|
|
|
session, the prepared statement must have been created by a
|
2002-08-27 06:55:12 +02:00
|
|
|
<command>PREPARE</command> statement executed earlier in the
|
|
|
|
current session.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-04-27 01:56:51 +02:00
|
|
|
If the <command>PREPARE</command> statement that created the statement
|
2002-08-27 06:55:12 +02:00
|
|
|
specified some parameters, a compatible set of parameters must be
|
|
|
|
passed to the <command>EXECUTE</command> statement, or else an
|
2003-04-27 01:56:51 +02:00
|
|
|
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.
|
2002-08-27 06:55:12 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2003-04-27 01:56:51 +02:00
|
|
|
For more information on the creation and usage of prepared statements,
|
2017-11-23 15:39:47 +01:00
|
|
|
see <xref linkend="sql-prepare"/>.
|
2002-08-27 06:55:12 +02:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2003-04-27 01:56:51 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Parameters</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2017-10-09 04:00:57 +02:00
|
|
|
<term><replaceable class="parameter">name</replaceable></term>
|
2003-04-27 01:56:51 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The name of the prepared statement to execute.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2002-08-27 06:55:12 +02:00
|
|
|
|
2003-04-27 01:56:51 +02:00
|
|
|
<varlistentry>
|
2017-10-09 04:00:57 +02:00
|
|
|
<term><replaceable class="parameter">parameter</replaceable></term>
|
2003-04-27 01:56:51 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The actual value of a parameter to the prepared statement. This
|
2006-01-15 23:18:47 +01:00
|
|
|
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.
|
2003-04-27 01:56:51 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
2004-01-26 18:26:31 +01:00
|
|
|
<refsect1>
|
2004-04-22 13:46:22 +02:00
|
|
|
<title>Outputs</title>
|
2004-01-26 18:26:31 +01:00
|
|
|
<para>
|
2004-04-22 13:46:22 +02:00
|
|
|
The command tag returned by <command>EXECUTE</command>
|
2017-10-09 03:44:17 +02:00
|
|
|
is that of the prepared statement, and not <literal>EXECUTE</literal>.
|
2004-04-22 13:46:22 +02:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
2017-10-09 03:44:17 +02:00
|
|
|
<title>Examples</title>
|
2004-04-22 13:46:22 +02:00
|
|
|
<para>
|
Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs.
Use xreflabel attributes instead of endterm attributes to control the
appearance of links to subsections of SQL command reference pages.
This is simpler, it matches what we do elsewhere (e.g. for GUC variables),
and it doesn't draw "Unresolved ID reference" warnings from the PDF
toolchain.
Fix some places where the text was absolutely dependent on an <xref>
rendering exactly so, by using a <link> around the required text
instead. At least one of those spots had already been turned into
bad grammar by subsequent changes, and the whole idea is just too
fragile for my taste. <xref> does NOT have fixed output, don't write
as if it does.
Consistently include a page-level link in cross-man-page references,
because otherwise they are useless/nonsensical in man-page output.
Likewise, be consistent about mentioning "below" or "above" in same-page
references; we were doing that in about 90% of the cases, but now it's
100%.
Also get rid of another nonfunctional-in-PDF idea, of making
cross-references to functions by sticking ID tags on <row> constructs.
We can put the IDs on <indexterm>s instead --- which is probably not any
more sensible in abstract terms, but it works where the other doesn't.
(There is talk of attaching cross-reference IDs to most or all of
the docs' function descriptions, but for now I just fixed the two
that exist.)
Discussion: https://postgr.es/m/14480.1589154358@sss.pgh.pa.us
2020-05-11 20:15:49 +02:00
|
|
|
Examples are given in <xref linkend="sql-prepare-examples"/>
|
|
|
|
in the <xref linkend="sql-prepare"/> documentation.
|
2004-01-26 18:26:31 +01:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2003-04-27 01:56:51 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Compatibility</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The SQL standard includes an <command>EXECUTE</command> statement,
|
|
|
|
but it is only for use in embedded SQL. This version of the
|
|
|
|
<command>EXECUTE</command> statement also uses a somewhat different
|
|
|
|
syntax.
|
|
|
|
</para>
|
2002-08-27 06:55:12 +02:00
|
|
|
</refsect1>
|
2004-09-20 02:04:19 +02:00
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
|
|
|
<simplelist type="inline">
|
2017-11-23 15:39:47 +01:00
|
|
|
<member><xref linkend="sql-deallocate"/></member>
|
|
|
|
<member><xref linkend="sql-prepare"/></member>
|
2004-09-20 02:04:19 +02:00
|
|
|
</simplelist>
|
|
|
|
</refsect1>
|
2002-08-27 06:55:12 +02:00
|
|
|
</refentry>
|