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

From: Richard Huxton <dev(at)archonet(dot)com>
To: Vang <vyang(at)apt-cafm(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: current transaction is aborted, commands ignored until end of transaction block
Date: 2007-05-30 20:33:01
Message-ID: 465DDF7D.9070704@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vang wrote:
> Hello,
>
> I'm using PostgreSQL 8.0 and Java in NetBeans IDE. In java I have a
> method that does a "insert into" and it throws a "duplicate key
> violates unique constraint." I call that method once and then call
> another method which does a "select." However, when the select
> method gets called postgres throws a "current transaction is aborted,
> commands ignored until end of transaction block." I've read some of
> the mailing list and it says if I set on_error_rollback to on it'll
> work; but when I use sql(from netbeans) to set it, it doesn't
> recognize on_error_rollback. My statement is as follows: set
> on_error_rollback = on

It's a psql interactive thing rather than something you can use from
other clients:
\set on_error_rollback
It's designed to help with spelling mistakes/scripts etc.

If you get an error back from an insert you need to catch it and
rollback yourself.

Of course by default, all PostgreSQL statements execute in their own
transaction. That would mean your SELECT would be fine, and implies
something in your JDBC setup is issuing "BEGIN" without your knowledge.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Kempter 2007-05-30 21:31:36 DRDB risk factors?
Previous Message Kevin Kempter 2007-05-30 19:46:35 pgpool redundancy question