Skip site navigation (1) Skip section navigation (2)

Re: AUTO COMMIT

From: Atif Jung <atifjung(at)gmail(dot)com>
To: "Jean-Yves F(dot) Barbier" <12ukwn(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: AUTO COMMIT
Date: 2010-07-01 16:30:28
Message-ID: AANLkTilNzhDsO6qL4EbgMJjHlzqm4ZuIrjigKst2wYrC@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
Sorry I'm still confused. as I said in my earlier e-mail I've built the
program using the -t option for ecpg. AUTOCOMMIT is set to on, however I
still get an error when opening a declared cursor:

"DECLARE CURSOR can only be used in transaction blocks".

If I stick a EXEC SQL BEGIN WORK before declaring the cursor it seems to
work ok, but I thought the -t option saves me from having to do that each
time.

Atif




On 28 June 2010 19:23, Jean-Yves F. Barbier <12ukwn(at)gmail(dot)com> wrote:

> Le Mon, 28 Jun 2010 15:56:51 +0100,
> Atif Jung <atifjung(at)gmail(dot)com> a écrit :
>
> ...
>  > "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 when
> > declaring a cursor:
> >
> > DECLARE CURSOR can only be used in transaction blocks.
> >
> > What am I doing wrong?
>
> autocommit means *every* line is begin/commit (or fails).
>
> --
> QOTD:
>        "He's so egotistical he yells his own name when he comes."
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>

In response to

pgsql-novice by date

Next:From: David JarvisDate: 2010-07-01 22:24:47
Subject: Invalid syntax for integer
Previous:From: Tom LaneDate: 2010-07-01 15:07:10
Subject: Re: How to find out whether a row is currently referenced by a row in a different table?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group