blob: 4ffacb1f8712a4c3cbdb5bd1caf9834d5e0ab46f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?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>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 16.3 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">
MOVE [ <em class="replaceable"><code>direction</code></em> ] [ FROM | IN ] <em class="replaceable"><code>cursor_name</code></em>
<span class="phrase">where <em class="replaceable"><code>direction</code></em> can be one of:</span>
NEXT
PRIOR
FIRST
LAST
ABSOLUTE <em class="replaceable"><code>count</code></em>
RELATIVE <em class="replaceable"><code>count</code></em>
<em class="replaceable"><code>count</code></em>
ALL
FORWARD
FORWARD <em class="replaceable"><code>count</code></em>
FORWARD ALL
BACKWARD
BACKWARD <em class="replaceable"><code>count</code></em>
BACKWARD ALL
</pre></div><div class="refsect1" id="id-1.9.3.157.6"><h2>Description</h2><p>
<code class="command">MOVE</code> repositions a cursor without retrieving any data.
<code class="command">MOVE</code> works exactly like the <code class="command">FETCH</code>
command, except it only positions the cursor and does not return rows.
</p><p>
The parameters for the <code class="command">MOVE</code> command are identical to
those of the <code class="command">FETCH</code> command; refer to
<a class="xref" href="sql-fetch.html" title="FETCH"><span class="refentrytitle">FETCH</span></a>
for details on syntax and usage.
</p></div><div class="refsect1" id="id-1.9.3.157.7"><h2>Outputs</h2><p>
On successful completion, a <code class="command">MOVE</code> command returns a command
tag of the form
</p><pre class="screen">
MOVE <em class="replaceable"><code>count</code></em>
</pre><p>
The <em class="replaceable"><code>count</code></em> is the number
of rows that a <code class="command">FETCH</code> command with the same parameters
would have returned (possibly zero).
</p></div><div class="refsect1" id="id-1.9.3.157.8"><h2>Examples</h2><pre class="programlisting">
BEGIN WORK;
DECLARE liahona CURSOR FOR SELECT * FROM films;
-- Skip the first 5 rows:
MOVE FORWARD 5 IN liahona;
MOVE 5
-- Fetch the 6th row from the cursor liahona:
FETCH 1 FROM liahona;
code | title | did | date_prod | kind | len
-------+--------+-----+------------+--------+-------
P_303 | 48 Hrs | 103 | 1982-10-22 | Action | 01:37
(1 row)
-- Close the cursor liahona and end the transaction:
CLOSE liahona;
COMMIT WORK;
</pre></div><div class="refsect1" id="id-1.9.3.157.9"><h2>Compatibility</h2><p>
There is no <code class="command">MOVE</code> statement in the SQL standard.
</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 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> NOTIFY</td></tr></table></div></body></html>
|