2 doc/src/sgml/ref/close.sgml
3 PostgreSQL documentation
6 <refentry id="SQL-CLOSE">
8 <refentrytitle>CLOSE</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
14 <refname>CLOSE</refname>
15 <refpurpose>close a cursor</refpurpose>
18 <indexterm zone="sql-close">
19 <primary>CLOSE</primary>
22 <indexterm zone="sql-close">
23 <primary>cursor</primary>
24 <secondary>CLOSE</secondary>
29 CLOSE { <replaceable class="PARAMETER">name</replaceable> | ALL }
34 <title>Description</title>
37 <command>CLOSE</command> frees the resources associated with an open cursor.
38 After the cursor is closed, no subsequent operations
39 are allowed on it. A cursor should be closed when it is
44 Every non-holdable open cursor is implicitly closed when a
45 transaction is terminated by <command>COMMIT</command> or
46 <command>ROLLBACK</command>. A holdable cursor is implicitly
47 closed if the transaction that created it aborts via
48 <command>ROLLBACK</command>. If the creating transaction
49 successfully commits, the holdable cursor remains open until an
50 explicit <command>CLOSE</command> is executed, or the client
56 <title>Parameters</title>
60 <term><replaceable class="PARAMETER">name</replaceable></term>
63 The name of an open cursor to close.
69 <term><literal>ALL</literal></term>
72 Close all open cursors.
84 <productname>PostgreSQL</productname> does not have an explicit
85 <command>OPEN</command> cursor statement; a cursor is considered
86 open when it is declared. Use the
87 <xref linkend="sql-declare">
88 statement to declare a cursor.
92 You can see all available cursors by querying the <link
93 linkend="view-pg-cursors"><structname>pg_cursors</></> system view.
97 If a cursor is closed after a savepoint which is later rolled back,
98 the <command>CLOSE</command> is not rolled back; that is, the cursor
104 <title>Examples</title>
107 Close the cursor <literal>liahona</literal>:
110 </programlisting></para>
114 <title>Compatibility</title>
117 <command>CLOSE</command> is fully conforming with the SQL
118 standard. <command>CLOSE ALL</> is a <productname>PostgreSQL</>
124 <title>See Also</title>
126 <simplelist type="inline">
127 <member><xref linkend="sql-declare"></member>
128 <member><xref linkend="sql-fetch"></member>
129 <member><xref linkend="sql-move"></member>