Medhavi Mahansaria <medhavi.mahansaria@tcs.com> wrote:
> I need to execute a series of queries
> in a transaction, say Q1, Q2, Q3.
>
> Q1 -> success
> Q2 -> Failed
> Q3 -> Success
>
> My issue is that after Q2 fails all
> the queries that follow give error"ERROR: current transaction
> is aborted, commands ignored until end of transaction block"
>
> I want to move ahead in the transaction
> and execute Q3 also even though Q2 was a failure.
>
> Can you please suggest a way to do so
> in PostgreSQL 9.3.
>
> Is there a way to turn autocommit off?
The server does not support that, but if you're running a script
through psql you should look at using:
\set ON_ERROR_ROLLBACK on
Docs at:
http://www.postgresql.org/docs/9.3/interactive/app-psql.html
If you are not using psql you can use savepoints:
http://www.postgresql.org/docs/8.4/interactive/sql-savepoint.html
ROLLBACK TO SAVEPOINT if the statement fails.
--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company