MOVE [ direction ] [ count ] { IN | FROM } cursor |
MOVE [ FORWARD | BACKWARD | RELATIVE ] [ # | ALL | NEXT | PRIOR ] { IN | FROM } cursor |
Defines the move direction. It can be one of the following:
Move to next row. This is the default.
Moves to previous row.
Determines how many rows to move. It can be one of the following:
A signed integer that specifies how many rows to move. Note that a negative integer is equivalent to changing the sense of FORWARD and BACKWARD.
Move all remaining rows.
Equivalent to specifying a count of 1.
Equivalent to specifying a count of -1.
Name of an open cursor.
MOVE allows a user to move cursor position a specified number of rows. MOVE works like the FETCH command, but only positions the cursor and does not return rows.
Set up and use a cursor:
BEGIN WORK; DECLARE liahona CURSOR FOR SELECT * FROM films; --Skip first 5 rows: MOVE FORWARD 5 IN liahona; MOVE --Fetch 6th row in the cursor liahona: FETCH 1 IN liahona; FETCH 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 commit work: CLOSE liahona; COMMIT WORK; |