MOVE
position a cursor
English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- anchor
- SQL-MOVE
- file
- sql-move.html
- lang
- en
- name
- MOVE
- purpose
- position a cursor
- purpose zh
- 定位游标
- sections same as
- Unknown
- slug
- 18
- synopsis text
- MOVE [ direction ] [ FROM | IN ] cursor_name where direction can be one of: NEXT PRIOR FIRST LAST ABSOLUTE count RELATIVE count count ALL FORWARD FORWARD count FORWARD ALL BACKWARD BACKWARD count BACKWARD ALL
Syntax
MOVE [ direction ] [ FROM | IN ] cursor_name
where direction can be one of:
NEXT
PRIOR
FIRST
LAST
ABSOLUTE count
RELATIVE count
count
ALL
FORWARD
FORWARD count
FORWARD ALL
BACKWARD
BACKWARD count
BACKWARD ALLSyntax diagrams
Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.
direction
Definition PG 18
MOVE [ direction ] [ FROM | IN ] cursor_name where direction can be one of: NEXT PRIOR FIRST LAST ABSOLUTE count RELATIVE count count ALL FORWARD FORWARD count FORWARD ALL BACKWARD BACKWARD count BACKWARD ALL
Description
MOVE repositions a cursor without retrieving any data. MOVE works exactly like the FETCH command, except it only positions the cursor and does not return rows.
The parameters for the MOVE command are identical to those of the FETCH command; refer to FETCH for details on syntax and usage.
Outputs
On successful completion, a MOVE command returns a command tag of the form
MOVE count
The count is the number of rows that a FETCH command with the same parameters would have returned (possibly zero).
Examples
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;
Compatibility
There is no MOVE statement in the SQL standard.
See Also
CLOSE, DECLARE, FETCHCompare versions
Complete source facts
synopsis html
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 ALLSource references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:9ffc68d25b74524f15e8b188c89c309e5a6944d35bd66fd4f26732671b92f000
Text language: en · wiki-repair-20261023:9ffc68d25b74524f15e8b188c89c309e5a6944d35bd66fd4f26732671b92f000