/
fetch.rst
101 lines (64 loc) · 1.6 KB
/
fetch.rst
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.. highlight:: psql
.. _sql-fetch:
=========
``FETCH``
=========
Fetch rows from a cursor.
.. contents::
:local:
.. _sql-fetch-synopsis:
Synopsis
========
::
FETCH [ direction [ FROM | IN ] ] cursor_name
Where direction can be empty or one of:
NEXT
RELATIVE count
ABSOLUTE position
count
ALL
FORWARD
FORWARD count
FORWARD ALL
Description
===========
Fetches rows from a cursor created using :ref:`DECLARE <sql-declare>`.
A cursor has a position and each time you use ``FETCH``, the position changes
and the rows spanning the position change get returned.
Parameters
===========
``direction``
.............
:NEXT:
Fetch the next row. This is the default
:RELATIVE count:
Fetch ``count`` rows relative to the current position.
:ABSOLUTE position:
Jumps to the ``position`` and returns the row, or an empty result if jumped to
a position outside the result set.
Jumping backward is only possible if the cursor was created with ``SCROLL``
set in ``DECLARE``.
:count:
Fetch the next ``count`` rows
:ALL:
Fetch all remaining rows
:FORWARD:
Same as ``NEXT``
:FORWARD count:
Same as ``count``
:FORWARD ALL:
Same as ``ALL``
:BACKWARD:
Move 1 row back
Moving backward is only possible if the cursor was created with ``SCROLL``
set in ``DECLARE``.
:BACKWARD count:
Move ``count`` rows back
Moving backward is only possible if the cursor was created with ``SCROLL``
set in ``DECLARE``.
``count``
.........
A integer constant, determining which or how many rows to fetch
``cursor_name``
...............
Name of the cursor to fetch rows from.