Re: strange commit behavior - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: strange commit behavior
Date
Msg-id gfu26d$eq5$1@ger.gmane.org
Whole thread Raw
In response to strange commit behavior  ("Flavio Palumbo" <f.palumbo@silmasoftware.com>)
List pgsql-general
Flavio Palumbo, 18.11.2008 10:01:
> I tested this tool under MySql and Oracle and everything went as expected.
>
> Unfortunately postgres seems to work in a different way, cause if there is
> just one error while the transaction is active I'm not able to commit the
> well formed data in the db, no matter if the good records were inserted
> sooner or later the error.
>
> Does this behavior appears right for postgres ?

Yes this is the way Postgres works (been there as well)

> There is any way or workaround to achieve my goal ?

You need to wrap each UPDATE/INSERT statement with a Savepoint

Savepoint sp = connection.setSavepoint()
try
{
  // do your insert/update/delete here
  connection.release(sp);
}
catch (SQLException sql)
{
  connection.rollback(sp);
}

Thomas

pgsql-general by date:

Previous
From: "Flavio Palumbo"
Date:
Subject: Commit strange behavior
Next
From: Richard Huxton
Date:
Subject: Re: Commit strange behavior