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

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: #Personal#: Reg: Multiple queries in a transaction
Дата
Msg-id 1342988397.596596.1424275841832.JavaMail.yahoo@mail.yahoo.com
обсуждение исходный текст
Ответ на #Personal#: Reg: Multiple queries in a transaction  (Medhavi Mahansaria <medhavi.mahansaria@tcs.com>)
Ответы Re: #Personal#: Reg: Multiple queries in a transaction  (Medhavi Mahansaria <medhavi.mahansaria@tcs.com>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Starting new cluster from base backup
Следующее
От: David G Johnston
Дата:
Сообщение: Re: #Personal#: Reg: Multiple queries in a transaction