]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/sql-move.html
PG 18 docs from https://ftp.postgresql.org/pub/source/v18.0/postgresql-18.0-docs...
[ai-pg] / full-docs / src / sgml / html / sql-move.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!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>MOVE</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="sql-merge.html" title="MERGE" /><link rel="next" href="sql-notify.html" title="NOTIFY" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">MOVE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-merge.html" title="MERGE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-notify.html" title="NOTIFY">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-MOVE"><div class="titlepage"></div><a id="id-1.9.3.157.1" class="indexterm"></a><a id="id-1.9.3.157.2" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">MOVE</span></h2><p>MOVE — position a cursor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
3 MOVE [ <em class="replaceable"><code>direction</code></em> ] [ FROM | IN ] <em class="replaceable"><code>cursor_name</code></em>
4
5 <span class="phrase">where <em class="replaceable"><code>direction</code></em> can be one of:</span>
6
7     NEXT
8     PRIOR
9     FIRST
10     LAST
11     ABSOLUTE <em class="replaceable"><code>count</code></em>
12     RELATIVE <em class="replaceable"><code>count</code></em>
13     <em class="replaceable"><code>count</code></em>
14     ALL
15     FORWARD
16     FORWARD <em class="replaceable"><code>count</code></em>
17     FORWARD ALL
18     BACKWARD
19     BACKWARD <em class="replaceable"><code>count</code></em>
20     BACKWARD ALL
21 </pre></div><div class="refsect1" id="id-1.9.3.157.6"><h2>Description</h2><p>
22    <code class="command">MOVE</code> repositions a cursor without retrieving any data.
23    <code class="command">MOVE</code> works exactly like the <code class="command">FETCH</code>
24    command, except it only positions the cursor and does not return rows.
25   </p><p>
26    The parameters for the <code class="command">MOVE</code> command are identical to
27    those of the <code class="command">FETCH</code> command; refer to
28    <a class="xref" href="sql-fetch.html" title="FETCH"><span class="refentrytitle">FETCH</span></a>
29    for details on syntax and usage.
30   </p></div><div class="refsect1" id="id-1.9.3.157.7"><h2>Outputs</h2><p>
31    On successful completion, a <code class="command">MOVE</code> command returns a command
32    tag of the form
33 </p><pre class="screen">
34 MOVE <em class="replaceable"><code>count</code></em>
35 </pre><p>
36    The <em class="replaceable"><code>count</code></em> is the number
37    of rows that a <code class="command">FETCH</code> command with the same parameters
38    would have returned (possibly zero).
39   </p></div><div class="refsect1" id="id-1.9.3.157.8"><h2>Examples</h2><pre class="programlisting">
40 BEGIN WORK;
41 DECLARE liahona CURSOR FOR SELECT * FROM films;
42
43 -- Skip the first 5 rows:
44 MOVE FORWARD 5 IN liahona;
45 MOVE 5
46
47 -- Fetch the 6th row from the cursor liahona:
48 FETCH 1 FROM liahona;
49  code  | title  | did | date_prod  |  kind  |  len
50 -------+--------+-----+------------+--------+-------
51  P_303 | 48 Hrs | 103 | 1982-10-22 | Action | 01:37
52 (1 row)
53
54 -- Close the cursor liahona and end the transaction:
55 CLOSE liahona;
56 COMMIT WORK;
57 </pre></div><div class="refsect1" id="id-1.9.3.157.9"><h2>Compatibility</h2><p>
58    There is no <code class="command">MOVE</code> statement in the SQL standard.
59   </p></div><div class="refsect1" id="id-1.9.3.157.10"><h2>See Also</h2><span class="simplelist"><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>, <a class="xref" href="sql-fetch.html" title="FETCH"><span class="refentrytitle">FETCH</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="sql-merge.html" title="MERGE">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-notify.html" title="NOTIFY">Next</a></td></tr><tr><td width="40%" align="left" valign="top">MERGE </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> NOTIFY</td></tr></table></div></body></html>