mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Add usage examples for PREPARE and EXECUTE. Original patch from Gavin
Sherry, editorializing by Neil Conway.
This commit is contained in:
		
							parent
							
								
									146aab497e
								
							
						
					
					
						commit
						f30d39e706
					
				| @ -1,5 +1,5 @@ | ||||
| <!-- | ||||
| $PostgreSQL: pgsql/doc/src/sgml/ref/execute.sgml,v 1.7 2003/11/29 19:51:38 pgsql Exp $ | ||||
| $PostgreSQL: pgsql/doc/src/sgml/ref/execute.sgml,v 1.8 2004/01/26 17:26:30 neilc Exp $ | ||||
| PostgreSQL documentation | ||||
| --> | ||||
| 
 | ||||
| @ -78,6 +78,15 @@ EXECUTE <replaceable class="PARAMETER">plan_name</replaceable> [ (<replaceable c | ||||
|   </variablelist> | ||||
|  </refsect1> | ||||
| 
 | ||||
|  <refsect1> | ||||
|   <title>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</title> | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <!-- | ||||
| $PostgreSQL: pgsql/doc/src/sgml/ref/prepare.sgml,v 1.10 2003/12/14 00:55:46 neilc Exp $ | ||||
| $PostgreSQL: pgsql/doc/src/sgml/ref/prepare.sgml,v 1.11 2004/01/26 17:26:31 neilc Exp $ | ||||
| PostgreSQL documentation | ||||
| --> | ||||
| 
 | ||||
| @ -139,6 +139,29 @@ PREPARE <replaceable class="PARAMETER">plan_name</replaceable> [ (<replaceable c | ||||
|   </para> | ||||
|  </refsect1> | ||||
| 
 | ||||
|  <refsect1 id="sql-prepare-examples"> | ||||
|   <title id="sql-prepare-examples-title">Examples</title> | ||||
|   <para> | ||||
|    Create a prepared query for an <command>INSERT</command> statement, | ||||
|    and then execute it: | ||||
| <programlisting> | ||||
| 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'); | ||||
| </programlisting> | ||||
|   </para> | ||||
| 
 | ||||
|   <para> | ||||
|    Create a prepared query for a <command>SELECT</command> statement, | ||||
|    and then execute it: | ||||
| <programlisting> | ||||
| 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); | ||||
| </programlisting> | ||||
|   </para> | ||||
|  </refsect1> | ||||
|  <refsect1> | ||||
|   <title>Compatibility</title> | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user