On 2021-Oct-07, rir wrote:
> For myself,
> 'FETCH [ <direction> [ FROM | IN ] ] <cursor_name>'
> clearly indicates that 'direction' is optional.
Hmm, aren't you misreading the scope of the outer square brackets? If
<direction> is optional independently of [FROM|IN], then the synopsis
should be
FETCH [ <direction> ] [ FROM | IN ] <cursor_name>
and I think that's correct, since all forms omitting any of these are
accepted:
alvherre=# begin;
BEGIN
alvherre=*# declare c scroll cursor with hold for select 1 ;
DECLARE CURSOR
alvherre=*# commit;
COMMIT
alvherre=# fetch forward from c;
?column?
----------
1
(1 fila)
alvherre=# fetch from c;
?column?
----------
(0 filas)
alvherre=# fetch BACKWARD c;
?column?
----------
1
(1 fila)
alvherre=# fetch c;
?column?
----------
(0 filas)
--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/