MOVE
Description
MOVE repositions a cursor without retrieving any data. MOVE works exactly like the FETCH statement, except it only repositions the cursor and does not return rows.
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 |
Parameters
The parameters of MOVE and FETCH commands are the same. For details, see Parameters in "FETCH."

On successful completion, the MOVE command returns a "MOVE count" tag, where count indicates the number of rows that the FETCH command with the same parameters would have returned (possibly zero).
Examples
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 |
-- Create a schema. openGauss=# CREATE SCHEMA tpcds; -- Create the tpcds.reason table. openGauss=# CREATE TABLE tpcds.reason ( r_reason_sk INTEGER NOT NULL, r_reason_id CHAR(16) NOT NULL, r_reason_desc VARCHAR(40) ); -- Insert multiple records into the table. openGauss=# INSERT INTO tpcds.reason VALUES (1, 'AAAAAAAABAAAAAAA', 'Xxxxxxxxx'),(2, 'AAAAAAAACAAAAAAA', ' Xxxxxxxxx'),(3, 'AAAAAAAADAAAAAAA', ' Xxxxxxxxx'),(4, 'AAAAAAAAEAAAAAAA', 'Not the product that was ordered'),(5, 'AAAAAAAAFAAAAAAA', 'Parts missing'),(6, 'AAAAAAAAGAAAAAAA', 'Does not work with a product that I have'),(7, 'AAAAAAAAHAAAAAAA', 'Gift exchange'); -- Start a transaction. openGauss=# START TRANSACTION; -- Define a cursor cursor1. openGauss=# CURSOR cursor1 FOR SELECT * FROM tpcds.reason; -- Skip the first three rows of cursor1. openGauss=# MOVE FORWARD 3 FROM cursor1; -- Fetch the first four rows from cursor1. openGauss=# FETCH 4 FROM cursor1; r_reason_sk | r_reason_id | r_reason_desc -------------+------------------+------------------------------------------------------------------------------------------------------ 4 | AAAAAAAAEAAAAAAA | Not the product that was ordered 5 | AAAAAAAAFAAAAAAA | Parts missing 6 | AAAAAAAAGAAAAAAA | Does not work with a product that I have 7 | AAAAAAAAHAAAAAAA | Gift exchange (4 rows) -- Close the cursor. openGauss=# CLOSE cursor1; -- End the transaction. openGauss=# END; -- Drop the table. openGauss=# DROP TABLE tpcds.reason; -- Drop the schema. openGauss=# DROP SCHEMA tpcds CASCADE; |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.