forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
12 KiB
12 KiB
MOVE
Function
MOVE repositions a cursor without retrieving any data. MOVE works exactly like the FETCH command, except it only repositions the cursor and does not return rows.
Precautions
None
Syntax
1 | MOVE [ direction [ FROM | IN ] ] cursor_name; |
The direction clause specifies optional parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | NEXT | PRIOR | FIRST | LAST | ABSOLUTE count | RELATIVE count | count | ALL | FORWARD | FORWARD count | FORWARD ALL | BACKWARD | BACKWARD count | BACKWARD ALL |
Parameter Description
MOVE command parameters are the same as FETCH command parameters. For details, see Parameter Description in FETCH.
Examples
Create table reason and insert data into it.
1 2 3 4 5 6 7 8 9 | DROP TABLE IF EXISTS reason; CREATE TABLE reason ( a int primary key, b int, c int ); INSERT INTO reason VALUES (1, 2, 3); |
Start a transaction:
1 | START TRANSACTION; |
Define the cursor1 cursor:
1 | CURSOR cursor1 FOR SELECT * FROM reason; |
Skip the first three rows of cursor1:
1 | MOVE FORWARD 3 FROM cursor1; |
Fetch the first four rows from cursor1:
1 | FETCH 4 FROM cursor1; |
Close a cursor:
1 | CLOSE cursor1; |
End the transaction:
1 | END; |
Parent topic: DDL Syntax