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

Re: Reg: 25P02, current transaction is aborted, commands ignored until end of transaction block

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: ajay labade <ajaylabade(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Reg: 25P02, current transaction is aborted, commands ignored until end of transaction block
Date: 2009-10-01 01:33:05
Message-ID: 603c8f070909301833w24b3529aw7f1b81f0d01fbf7b@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Wed, Sep 30, 2009 at 5:23 AM, ajay labade <ajaylabade(at)gmail(dot)com> wrote:
>>     I am trying to port my application from Oracle to PostGREs. I have a
>> problem while doing so. In my application i need to update record if the
>> delete on the respective record is failed due to Constraint Violation. But
>> SQL Error: 0, SQLState: 25P02 ERROR [JDBCExceptionReporter] ERROR: current
>> transaction is aborted, commands ignored until end of transaction block is
>> being generated while updating the record. But with Oracle i am able to do
>> this.
>>
>> I have tried with latest Jar [postgresql-8.3-604.jdbc3.jar] too, but
>> problem still exists.
>>
>> Here is the code that i worked on:
>>
>> try{
>>     session = sessionManager.getSession();
>>     transaction = session.beginTransaction();
>>     session.delete(objects[i]);
>>     session.flush();
>> }catch(ConstraintViolationException e){
>>     objects[i].setDeleted(Integer.valueOf(1));
>>     session.saveOrUpdate(object[i]);
>>     session.flush();
>> }
>> transaction.commit();
>> sessionManager.closeSession(session);

This is not a bug.

When an exception occurs in PostgreSQL, any further commands are
ignored until the transaction is rolled back.  In this case, you seem
to be catching a ConstraintViolationException and then attempting to
performing further database actions, which is bound to fail.

You may want to ROLLBACK within your exception handler and then BEGIN again.

...Robert

In response to

pgsql-bugs by date

Next:From: mauro.infantinoDate: 2009-10-01 03:58:01
Subject: Re: BUG #5076: LEFT OUTER JOIN and WHERE madness
Previous:From: Tom LaneDate: 2009-09-30 21:01:42
Subject: Re: Bus Error in psql command history

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