Postgresql 中文操作指南

MOVE

MOVE——将光标定位到一个位置

Synopsis

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 重新定位光标,而不检索任何数据。 MOVE 的工作原理与 FETCH 命令完全相同,除了它只定位光标,而不返回行。

MOVE 命令的参数与 FETCH 命令中的参数相同;有关语法和使用情况的详细信息,请参阅 FETCH

Outputs

如果成功完成, MOVE 命令将返回以下形式的命令标记:

MOVE count

count 是具有相同参数的 FETCH 命令将返回的行数(可能为零)。

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

SQL 标准中没有 MOVE 语句。

See Also

CLOSEDECLAREFETCH