Search Postgresql Archives

Re: #Personal#: Reg: Multiple queries in a transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Medhavi Mahansaria <medhavi.mahansaria@xxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux