1<!-- 2doc/src/sgml/ref/execute.sgml 3PostgreSQL documentation 4--> 5 6<refentry id="SQL-EXECUTE"> 7 <indexterm zone="sql-execute"> 8 <primary>EXECUTE</primary> 9 </indexterm> 10 11 <indexterm zone="sql-execute"> 12 <primary>prepared statements</primary> 13 <secondary>executing</secondary> 14 </indexterm> 15 16 <refmeta> 17 <refentrytitle>EXECUTE</refentrytitle> 18 <manvolnum>7</manvolnum> 19 <refmiscinfo>SQL - Language Statements</refmiscinfo> 20 </refmeta> 21 22 <refnamediv> 23 <refname>EXECUTE</refname> 24 <refpurpose>execute a prepared statement</refpurpose> 25 </refnamediv> 26 27 <refsynopsisdiv> 28<synopsis> 29EXECUTE <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable class="PARAMETER">parameter</replaceable> [, ...] ) ] 30</synopsis> 31 </refsynopsisdiv> 32 33 <refsect1> 34 <title>Description</title> 35 36 <para> 37 <command>EXECUTE</command> is used to execute a previously prepared 38 statement. Since prepared statements only exist for the duration of a 39 session, the prepared statement must have been created by a 40 <command>PREPARE</command> statement executed earlier in the 41 current session. 42 </para> 43 44 <para> 45 If the <command>PREPARE</command> statement that created the statement 46 specified some parameters, a compatible set of parameters must be 47 passed to the <command>EXECUTE</command> statement, or else an 48 error is raised. Note that (unlike functions) prepared statements are 49 not overloaded based on the type or number of their parameters; the 50 name of a prepared statement must be unique within a database session. 51 </para> 52 53 <para> 54 For more information on the creation and usage of prepared statements, 55 see <xref linkend="sql-prepare">. 56 </para> 57 </refsect1> 58 59 <refsect1> 60 <title>Parameters</title> 61 62 <variablelist> 63 <varlistentry> 64 <term><replaceable class="PARAMETER">name</replaceable></term> 65 <listitem> 66 <para> 67 The name of the prepared statement to execute. 68 </para> 69 </listitem> 70 </varlistentry> 71 72 <varlistentry> 73 <term><replaceable class="PARAMETER">parameter</replaceable></term> 74 <listitem> 75 <para> 76 The actual value of a parameter to the prepared statement. This 77 must be an expression yielding a value that is compatible with 78 the data type of this parameter, as was determined when the 79 prepared statement was created. 80 </para> 81 </listitem> 82 </varlistentry> 83 </variablelist> 84 </refsect1> 85 86 <refsect1> 87 <title>Outputs</title> 88 <para> 89 The command tag returned by <command>EXECUTE</command> 90 is that of the prepared statement, and not <literal>EXECUTE</>. 91 </para> 92 </refsect1> 93 94 <refsect1> 95 <title>Examples</> 96 <para> 97 Examples are given in the <xref linkend="sql-prepare-examples" 98 endterm="sql-prepare-examples-title"> section of the <xref 99 linkend="sql-prepare"> documentation. 100 </para> 101 </refsect1> 102 103 <refsect1> 104 <title>Compatibility</title> 105 106 <para> 107 The SQL standard includes an <command>EXECUTE</command> statement, 108 but it is only for use in embedded SQL. This version of the 109 <command>EXECUTE</command> statement also uses a somewhat different 110 syntax. 111 </para> 112 </refsect1> 113 114 <refsect1> 115 <title>See Also</title> 116 117 <simplelist type="inline"> 118 <member><xref linkend="sql-deallocate"></member> 119 <member><xref linkend="sql-prepare"></member> 120 </simplelist> 121 </refsect1> 122</refentry> 123