Re: pg and transactions

From: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
To: Oskar Berggren <beo(at)sgs(dot)studenthem(dot)gu(dot)se>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg and transactions
Date: 2002-12-28 15:48:20
Message-ID: 3E0DC7C4.68CBCA25@t1.unisoftbg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
Thanks for response,

I am using pg 7.2.3.
Actualy I am using Statement stmt = MyConnection.createStatement();

Is it possible that I need Statement stmt =
MyConnection.createStatement(ResultSet.TYPE_FROWARD_ONLY,ResultSet.CONCUR_UPDATABLE)
?

I nedd that after the beinn transaction all the selects and updates from the
first transaction to go to the end and after it to run the second.

regards,
ivan.

Oskar Berggren wrote:

> What are your actual queries? What version of Postgresql?
> Are you using FOR UPDATE in your select statements?
>
> /Oskar
>
> On Sat, 28 Dec 2002, pginfo wrote:
>
> > Hi,
> >
> > I think I have problem with pg transactions ( or I do not understend how
> > it work).
> >
> > I have two connections ( running on java clients via jdbc).
> >
> > I have one simple table tableA (ID int, value float8 ) with one record
> > (1,1000).
> >
> > And make this steps:
> >
> > Connection1-> begin transaction
> > Connection1-> read the record from tableA ( select values from tableA
> > where ID = 1). It returns 1000.
> > Connection1-> increase the value to 1001.
> > Connection1-> update the new value in tableA by update tableA set value
> > = 1001 where ID = 1.
> > Connection2-> begin transaction
> > Connection2-> read the record from tableA ( select values from tableA
> > where ID = 1). It returns 1000. !!!
> > Connection2-> increase the value with 1. It gives 1001.
> > Connection2-> update the new value in tableA by update tableA set value
> > = 1001 where ID = 1.
> > Connection2->commit.
> >
> > do some other jobs with connection1.
> >
> > Connection1->commit
> >
> > Actualy I use the table as a simple counter for unique values and I
> > expect that Connection2 will wait until Connection1 finish the task.
> > Is it normal for pg to work so with transactions?
> > If yes how can I lock all the tables after beginning the transaction?
> > If no where can I make mistake?
> >
> > The same example is working well on oracle and all the task is to port
> > one oracle based application to pg.
> >
> > Many tanks and regards,
> > ivan.
> >
> >
> >
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oskar Berggren 2002-12-28 16:19:25 Re: pg and transactions
Previous Message pginfo 2002-12-28 15:13:17 pg and transactions