From: Neil Conway Date: Mon, 26 Jan 2004 17:26:31 +0000 (+0000) Subject: Add usage examples for PREPARE and EXECUTE. Original patch from Gavin X-Git-Tag: REL8_0_0BETA1~1276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f30d39e706568f375291c8e2e14cf19ba84477dc;p=postgresql Add usage examples for PREPARE and EXECUTE. Original patch from Gavin Sherry, editorializing by Neil Conway. --- diff --git a/doc/src/sgml/ref/execute.sgml b/doc/src/sgml/ref/execute.sgml index c182ae0624..83c9fa91aa 100644 --- a/doc/src/sgml/ref/execute.sgml +++ b/doc/src/sgml/ref/execute.sgml @@ -1,5 +1,5 @@ @@ -78,6 +78,15 @@ EXECUTE plan_name [ ( + + Examples</> + <para> + Examples are given in the <xref linkend="sql-prepare-examples" + endterm="sql-prepare-examples-title"> section of the <xref + linkend="sql-prepare" endterm="sql-prepare-title"> documentation. + </para> + </refsect1> + <refsect1> <title>Compatibility diff --git a/doc/src/sgml/ref/prepare.sgml b/doc/src/sgml/ref/prepare.sgml index e7190b1b17..780c5231c4 100644 --- a/doc/src/sgml/ref/prepare.sgml +++ b/doc/src/sgml/ref/prepare.sgml @@ -1,5 +1,5 @@ @@ -139,6 +139,29 @@ PREPARE plan_name [ ( + + Examples + + Create a prepared query for an INSERT statement, + and then execute it: + +PREPARE fooplan (int, text, bool, numeric(8,2)) AS + INSERT INTO foo VALUES($1, '$2', '$3', '$4'); +EXECUTE fooplan(1, 'Hunter Valley', 't', '200.00'); + + + + + Create a prepared query for a SELECT statement, + and then execute it: + +PREPARE usrrptplan (int, date) AS + SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid + AND l.date = $2; +EXECUTE usrrptplan(1, current_date); + + + Compatibility