FETCH FORWARD 0 and "cursor can only scan forward" error

Поиск
Список
Период
Сортировка
От Trigve Siver
Тема FETCH FORWARD 0 and "cursor can only scan forward" error
Дата
Msg-id 1378300013.77628.YahooMailNeo@web125704.mail.ne1.yahoo.com
обсуждение исходный текст
Ответы Re: FETCH FORWARD 0 and "cursor can only scan forward" error  (Giuseppe Broccolo <giuseppe.broccolo@2ndquadrant.it>)
Re: FETCH FORWARD 0 and "cursor can only scan forward" error  (David Johnston <polobo@yahoo.com>)
Список pgsql-general
Hi,
I'm on PostgreSQL 9.2.2 and trying to use no scroll cursor for some data fetch. But when moving cursor ahead one record
andthe fetching the actual record the error "cursor can only scan forward" is returned. I don't know if I'm doing
somethingwrong but I don't think I'm going backward with cursor. Here is the code that demonstrate it  

BEGIN;

DECLARE CUR_1 NO SCROLL CURSOR WITHOUT HOLD FOR SELECT * FROM GENERATE_SERIES(1, 2);

FETCH FORWARD 0 FROM CUR_1; -- 0

MOVE FORWARD FROM CUR_1;

FETCH FORWARD 0 FROM CUR_1; -- 1

ABORT;

The line marked as "-- 0" is working OK, the line marked as "-- 1" is throwing error:

ERROR:  cursor can only scan forward
HINT:  Declare it with SCROLL option to enable backward scan.

********** Error **********

ERROR: cursor can only scan forward
SQL state: 55000
Hint: Declare it with SCROLL option to enable backward scan.

I want to iterate all records with cursor from beginning to end. This sample could be rewritten using FETCH FORWARD 1
...without using MOVE but I'm interested with solution which throws error. 

Thank you

Trigve


В списке pgsql-general по дате отправления:

Предыдущее
От: Eduardo Morras
Дата:
Сообщение: Re: Call for design: PostgreSQL mugs
Следующее
От: Evan Martin
Дата:
Сообщение: Spurious error messages from pg_restore