Re: write a sql block which will commit if both updates are successful else it will have to be rolled back

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: write a sql block which will commit if both updates are successful else it will have to be rolled back
Дата
Msg-id CAKFQuwZaPyVn4KzAO+aU16PWeCM6tFy9-A+wGim6So82Jg-krQ@mail.gmail.com
обсуждение исходный текст
Ответ на write a sql block which will commit if both updates are successful else it will have to be rolled back  (arun chirappurath <arunsnmimt@gmail.com>)
Список pgsql-general
On Thursday, December 7, 2023, arun chirappurath <arunsnmimt@gmail.com> wrote:

Can someone guide me to "write a sql block which will commit if both updates are successful else it will have to be rolled back"?
would like to explicitly specify both commit and rollback in code..

 I would like to turn off the autocommit then execute the query.

As documented under DO if you make an explicit transaction then execute the DO it cannot have transaction control commands.  If you allow it to “auto-commit’’ then it can.  Though in that case writing either rollback or commit for such a simple linear procedure becomes pointless since a transaction will already commit or rollback appropriately depending on whether the procedure provokes an exception.

David J.

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

Предыдущее
От: arun chirappurath
Дата:
Сообщение: write a sql block which will commit if both updates are successful else it will have to be rolled back
Следующее
От: Noel Jones
Дата:
Сообщение: Invalid Parent Index Issue Will Not Resolve Despite Multiple Attempts To Fix