Thread: ECPG: AUTOCOMMIT and CURSORs

ECPG: AUTOCOMMIT and CURSORs

From
A J
Date:
I am seeing some funny behavior on using both:
EXEC SQL SET AUTOCOMMIT TO ON;
and
CURSORS (EXEC SQL DECLARE ............., EXEC SQL FETCH NEXT FROM .............)

On autocommit on (either through above method or precompiling with -t option), the cursor does not return any rows. On disabling autocommit, I get the required number of rows from the cursor.

Any idea what could be going on ? 

Thanks!
AJ

Re: ECPG: AUTOCOMMIT and CURSORs

From
"Kevin Grittner"
Date:
A J <s5aly@yahoo.com> wrote:

> I am seeing some funny behavior on using both:
> EXEC SQL SET AUTOCOMMIT TO ON;
> and
> CURSORS (EXEC SQL DECLARE ............., EXEC SQL FETCH NEXT FROM
> .............)
>
> On autocommit on (either through above method or precompiling with
> -t option),
> the cursor does not return any rows. On disabling autocommit, I
> get the required number of rows from the cursor.
>
> Any idea what could be going on ?

Are you inside of a transaction?  How does the WITH or WITHOUT HOLD
function in ECPG?  From the manual:

http://www.postgresql.org/docs/current/interactive/sql-declare.html

"WITHOUT HOLD specifies that the cursor cannot be used outside of
the transaction that created it. If neither WITHOUT HOLD nor WITH
HOLD is specified, WITHOUT HOLD is the default."

-Kevin

Re: ECPG: AUTOCOMMIT and CURSORs

From
A J
Date:
That would explain it. I was neither in a transaction nor did any explicit HOLD. Thanks Kevin.


From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: pgsql-admin@postgresql.org; A J <s5aly@yahoo.com>
Sent: Mon, October 4, 2010 5:20:14 PM
Subject: Re: [ADMIN] ECPG: AUTOCOMMIT and CURSORs

A J <s5aly@yahoo.com> wrote:

> I am seeing some funny behavior on using both:
> EXEC SQL SET AUTOCOMMIT TO ON;
> and
> CURSORS (EXEC SQL DECLARE ............., EXEC SQL FETCH NEXT FROM
> .............)
>
> On autocommit on (either through above method or precompiling with
> -t option),
> the cursor does not return any rows. On disabling autocommit, I
> get the required number of rows from the cursor.
>
> Any idea what could be going on ?

Are you inside of a transaction?  How does the WITH or WITHOUT HOLD
function in ECPG?  From the manual:

http://www.postgresql.org/docs/current/interactive/sql-declare.html

"WITHOUT HOLD specifies that the cursor cannot be used outside of
the transaction that created it. If neither WITHOUT HOLD nor WITH
HOLD is specified, WITHOUT HOLD is the default."

-Kevin