Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf30d39e

Browse files
author
Neil Conway
committed
Add usage examples for PREPARE and EXECUTE. Original patch from Gavin
Sherry, editorializing by Neil Conway.
1 parent146aab4 commitf30d39e

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

‎doc/src/sgml/ref/execute.sgml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/execute.sgml,v 1.7 2003/11/29 19:51:38 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/execute.sgml,v 1.8 2004/01/26 17:26:30 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -78,6 +78,15 @@ EXECUTE <replaceable class="PARAMETER">plan_name</replaceable> [ (<replaceable c
7878
</variablelist>
7979
</refsect1>
8080

81+
<refsect1>
82+
<title>Examples</>
83+
<para>
84+
Examples are given in the <xref linkend="sql-prepare-examples"
85+
endterm="sql-prepare-examples-title"> section of the <xref
86+
linkend="sql-prepare" endterm="sql-prepare-title"> documentation.
87+
</para>
88+
</refsect1>
89+
8190
<refsect1>
8291
<title>Compatibility</title>
8392

‎doc/src/sgml/ref/prepare.sgml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/prepare.sgml,v 1.10 2003/12/14 00:55:46 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/prepare.sgml,v 1.11 2004/01/26 17:26:31 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -139,6 +139,29 @@ PREPARE <replaceable class="PARAMETER">plan_name</replaceable> [ (<replaceable c
139139
</para>
140140
</refsect1>
141141

142+
<refsect1 id="sql-prepare-examples">
143+
<title id="sql-prepare-examples-title">Examples</title>
144+
<para>
145+
Create a prepared query for an <command>INSERT</command> statement,
146+
and then execute it:
147+
<programlisting>
148+
PREPARE fooplan (int, text, bool, numeric(8,2)) AS
149+
INSERT INTO foo VALUES($1, '$2', '$3', '$4');
150+
EXECUTE fooplan(1, 'Hunter Valley', 't', '200.00');
151+
</programlisting>
152+
</para>
153+
154+
<para>
155+
Create a prepared query for a <command>SELECT</command> statement,
156+
and then execute it:
157+
<programlisting>
158+
PREPARE usrrptplan (int, date) AS
159+
SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid
160+
AND l.date = $2;
161+
EXECUTE usrrptplan(1, current_date);
162+
</programlisting>
163+
</para>
164+
</refsect1>
142165
<refsect1>
143166
<title>Compatibility</title>
144167

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp