summaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/move.sgml
blob: ed64f23068999c66412d2c0685da018bf29d878e (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!--
doc/src/sgml/ref/move.sgml
PostgreSQL documentation
-->

<refentry id="SQL-MOVE">
 <indexterm zone="sql-move">
  <primary>MOVE</primary>
 </indexterm>

 <indexterm zone="sql-move">
  <primary>cursor</primary>
  <secondary>MOVE</secondary>
 </indexterm>

 <refmeta>
  <refentrytitle>MOVE</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>MOVE</refname>
  <refpurpose>position a cursor</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<!-- Note the "direction" bit is also in ref/fetch.sgml -->
<synopsis>
MOVE [ <replaceable class="PARAMETER">direction</replaceable> [ FROM | IN ] ] <replaceable class="PARAMETER">cursor_name</replaceable>

<phrase>where <replaceable class="PARAMETER">direction</replaceable> can be empty or one of:</phrase>

    NEXT
    PRIOR
    FIRST
    LAST
    ABSOLUTE <replaceable class="PARAMETER">count</replaceable>
    RELATIVE <replaceable class="PARAMETER">count</replaceable>
    <replaceable class="PARAMETER">count</replaceable>
    ALL
    FORWARD
    FORWARD <replaceable class="PARAMETER">count</replaceable>
    FORWARD ALL
    BACKWARD
    BACKWARD <replaceable class="PARAMETER">count</replaceable>
    BACKWARD ALL
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>MOVE</command> repositions a cursor without retrieving any data.
   <command>MOVE</command> works exactly like the <command>FETCH</command>
   command, except it only positions the cursor and does not return rows.
  </para>

  <para>
   The parameters for the <command>MOVE</command> command are identical to
   those of the <command>FETCH</command> command; refer to
   <xref linkend="sql-fetch">
   for details on syntax and usage.
  </para>
 </refsect1>

 <refsect1>
  <title>Outputs</title>

  <para>
   On successful completion, a <command>MOVE</> command returns a command
   tag of the form
<screen>
MOVE <replaceable class="parameter">count</replaceable>
</screen>
   The <replaceable class="parameter">count</replaceable> is the number
   of rows that a <command>FETCH</command> command with the same parameters
   would have returned (possibly zero).
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

<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;
</programlisting>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   There is no <command>MOVE</command> statement in the SQL standard.
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-close"></member>
   <member><xref linkend="sql-declare"></member>
   <member><xref linkend="sql-fetch"></member>
  </simplelist>
 </refsect1>
</refentry>