Re: DECLARE CURSOR

Поиск
Список
Период
Сортировка
От Atif Jung
Тема Re: DECLARE CURSOR
Дата
Msg-id AANLkTikAo3LLSxxxX5pNA6s-R1-Y3T8SzIKTikJh-PWj@mail.gmail.com
обсуждение исходный текст
Ответ на Re: DECLARE CURSOR  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Thanks Tom,
 
The postgres manual states:
 
"In the default mode, statements are committed only when EXEC SQL COMMIT is issued. The embedded SQL interface also supports autocommit of transactions (similar to libpq behavior) via the -t command-line option to ecpg (see below) or via the EXEC SQL SET AUTOCOMMIT TO ON statement. In autocommit mode, each command is automatically committed unless it is inside an explicit transaction block. This mode can be explicitly turned off using EXEC SQL SET AUTOCOMMIT TO OFF."
 
I've used the -t command-line option when compiling my code, and AUTOCOMMIT is set, but I still get the following error message whenever I OPEN a cursor I've already DECLARED.
 
DECLARE CURSOR can only be used in transaction blocks.
 
What am I doing wrong?
 
Thanks
Atif




On 28 June 2010 15:00, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Atif Jung <atifjung@gmail.com> writes:
> I'm getting an error msg which reads:
> DECLARE CURSOR can only be used in transaction blocks.

> does that mean to DECLARE a cursor I must surrond it with a BEGIN & COMMIT
> work?

Yes.  The cursor automatically disappears as soon as you commit, so it'd
be useless otherwise.

                       regards, tom lane

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

Предыдущее
От: Atif Jung
Дата:
Сообщение: AUTO COMMIT
Следующее
От: Greg
Дата:
Сообщение: Postgre Protocol