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

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: arun chirappurath <arunsnmimt(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: write a sql block which will commit if both updates are successful else it will have to be rolled back
Date: 2023-12-07 19:52:45
Message-ID: CAKFQuwZaPyVn4KzAO+aU16PWeCM6tFy9-A+wGim6So82Jg-krQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, December 7, 2023, arun chirappurath <arunsnmimt(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Noel Jones 2023-12-07 22:38:53 Invalid Parent Index Issue Will Not Resolve Despite Multiple Attempts To Fix
Previous Message arun chirappurath 2023-12-07 19:37:24 write a sql block which will commit if both updates are successful else it will have to be rolled back