summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/ecpg-sql-declare.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/html/ecpg-sql-declare.html')
-rw-r--r--doc/src/sgml/html/ecpg-sql-declare.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/doc/src/sgml/html/ecpg-sql-declare.html b/doc/src/sgml/html/ecpg-sql-declare.html
new file mode 100644
index 0000000..03ec0a4
--- /dev/null
+++ b/doc/src/sgml/html/ecpg-sql-declare.html
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>DECLARE</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="ecpg-sql-deallocate-descriptor.html" title="DEALLOCATE DESCRIPTOR" /><link rel="next" href="ecpg-sql-declare-statement.html" title="DECLARE STATEMENT" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">DECLARE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="ecpg-sql-deallocate-descriptor.html" title="DEALLOCATE DESCRIPTOR">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="ecpg-sql-commands.html" title="36.14. Embedded SQL Commands">Up</a></td><th width="60%" align="center">36.14. Embedded SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="ecpg-sql-declare-statement.html" title="DECLARE STATEMENT">Next</a></td></tr></table><hr /></div><div class="refentry" id="ECPG-SQL-DECLARE"><div class="titlepage"></div><div class="refnamediv"><h2>DECLARE</h2><p>DECLARE — define a cursor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
+DECLARE <em class="replaceable"><code>cursor_name</code></em> [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <em class="replaceable"><code>prepared_name</code></em>
+DECLARE <em class="replaceable"><code>cursor_name</code></em> [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ] CURSOR [ { WITH | WITHOUT } HOLD ] FOR <em class="replaceable"><code>query</code></em>
+</pre></div><div class="refsect1" id="id-1.7.5.20.6.3"><h2>Description</h2><p>
+ <code class="command">DECLARE</code> declares a cursor for iterating over
+ the result set of a prepared statement. This command has
+ slightly different semantics from the direct SQL
+ command <code class="command">DECLARE</code>: Whereas the latter executes a
+ query and prepares the result set for retrieval, this embedded
+ SQL command merely declares a name as a <span class="quote">“<span class="quote">loop
+ variable</span>”</span> for iterating over the result set of a query;
+ the actual execution happens when the cursor is opened with
+ the <code class="command">OPEN</code> command.
+ </p></div><div class="refsect1" id="id-1.7.5.20.6.4"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>cursor_name</code></em></span></dt><dd><p>
+ A cursor name, case sensitive. This can be an SQL identifier
+ or a host variable.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>prepared_name</code></em></span></dt><dd><p>
+ The name of a prepared query, either as an SQL identifier or a
+ host variable.
+ </p></dd><dt><span class="term"><em class="replaceable"><code>query</code></em></span></dt><dd><p>
+ A <a class="xref" href="sql-select.html" title="SELECT"><span class="refentrytitle">SELECT</span></a> or
+ <a class="xref" href="sql-values.html" title="VALUES"><span class="refentrytitle">VALUES</span></a> command which will provide the
+ rows to be returned by the cursor.
+ </p></dd></dl></div><p>
+ For the meaning of the cursor options,
+ see <a class="xref" href="sql-declare.html" title="DECLARE"><span class="refentrytitle">DECLARE</span></a>.
+ </p></div><div class="refsect1" id="id-1.7.5.20.6.5"><h2>Examples</h2><p>
+ Examples declaring a cursor for a query:
+</p><pre class="programlisting">
+EXEC SQL DECLARE C CURSOR FOR SELECT * FROM My_Table;
+EXEC SQL DECLARE C CURSOR FOR SELECT Item1 FROM T;
+EXEC SQL DECLARE cur1 CURSOR FOR SELECT version();
+</pre><p>
+ </p><p>
+ An example declaring a cursor for a prepared statement:
+</p><pre class="programlisting">
+EXEC SQL PREPARE stmt1 AS SELECT version();
+EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
+</pre><p>
+ </p></div><div class="refsect1" id="id-1.7.5.20.6.6"><h2>Compatibility</h2><p>
+ <code class="command">DECLARE</code> is specified in the SQL standard.
+ </p></div><div class="refsect1" id="id-1.7.5.20.6.7"><h2>See Also</h2><span class="simplelist"><a class="xref" href="ecpg-sql-open.html" title="OPEN">OPEN</a>, <a class="xref" href="sql-close.html" title="CLOSE"><span class="refentrytitle">CLOSE</span></a>, <a class="xref" href="sql-declare.html" title="DECLARE"><span class="refentrytitle">DECLARE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ecpg-sql-deallocate-descriptor.html" title="DEALLOCATE DESCRIPTOR">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ecpg-sql-commands.html" title="36.14. Embedded SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ecpg-sql-declare-statement.html" title="DECLARE STATEMENT">Next</a></td></tr><tr><td width="40%" align="left" valign="top">DEALLOCATE DESCRIPTOR </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> DECLARE STATEMENT</td></tr></table></div></body></html> \ No newline at end of file