Re: DECLARE CURSOR

From: Haris Peco <snpe(at)snpe(dot)co(dot)yu>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: DECLARE CURSOR
Date: 2002-11-18 17:32:36
Message-ID: 200211181732.36108.snpe@snpe.co.yu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Monday 18 November 2002 05:13 pm, scott.marlowe wrote:
> On Sun, 17 Nov 2002, snpe wrote:
> > On Sunday 17 November 2002 05:46 am, Frank Miles wrote:
> > > On Sat, 16 Nov 2002, snpe wrote:
> > > > On Saturday 16 November 2002 09:29 pm, Frank Miles wrote:
> > > > > On Fri, 15 Nov 2002, snpe wrote:
> > > > > > Hello,
> > > > > > When I call DECLARE CURSOR out of transaction command success,
> > > > > > but cursor is not created
> > > > > > Reference manual say that this get error :
> > > > > > ERROR: DECLARE CURSOR may only be used in begin/end transaction
> > > > > > blocks I don't find this text in pgsql source code
> > > > > > What is problem ?
> > > > >
> > > > > According to the documentation for DECLARE CURSOR (v.7.2.x):
> > > > >
> > > > > "Cursors are only available in transactions. Use to BEGIN, COMMIT
> > > > > and ROLLBACK to define a transaction block."
> > > > >
> > > > > This seems consistent with your error message. Please try
> > > > > wrapping your DECLARE inside a transaction using BEGIN,...
> > > >
> > > > I understand it.
> > > > I don't understand why 'DECLARE CURSOR' success out of a transaction
> > > > - I expect error
> > >
> > > What version are you using? At least with 7.2.x, there is an immediate
> > > error at the DECLARE statement. Perhaps I am misunderstanding your
> > > question?
> >
> > 7.3b5
> > maybe, it is prepare for cursor out of a transaction (I hope)
>
> No, you just have autocommit turned off. Which means that the second you
> connect and type a command, Postgresql does an invisible begin for you.
> I.e. you're ALWAYS in an uncommitted transaction. Note that you'll have
> to issue a commit to get your changes into the database.
>
>

I want do next :
table - big table and select work with cursor only
I select row and if any condition is true I do transaction on another table
I can't do all in one transaction (performance reason) - for some rows in
table I do transaction

How can I do this ?

Thanks
Haris Peco

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Haris Peco 2002-11-18 17:36:00 Re: [GENERAL] DECLARE CURSOR
Previous Message Ed Brown 2002-11-18 17:16:39 newbie psql error opening libpq.so.2

Browse pgsql-hackers by date

  From Date Subject
Next Message Tim Bunce 2002-11-18 17:33:56 Re: DBD::PostgreSQL
Previous Message Bruce Momjian 2002-11-18 17:17:08 Re: CLUSTER ALL syntax