Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
Cc: Christophe Pettus <xof(at)thebuild(dot)com>, Ravi Krishna <s_ravikrishna(at)aol(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Date: 2022-10-18 21:33:37
Message-ID: 2746245.1666128817@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bryn Llewellyn <bryn(at)yugabyte(dot)com> writes:
> xof(at)thebuild(dot)com wrote:
>> You can commit in a loop, but not in BEGIN / END block that has an exception handler: that creates a subtransaction for the duration of the BEGIN / END.

> This surprised me when I first started to use PG (after all those years
> with ORCL).

Really? BEGIN with an exception block is a subtransaction because it's
defined to roll back to the database state as of the start of the block
if an exception occurs. COMMIT in the middle fundamentally conflicts
with that, I should think. Does Oracle interpret that differently?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2022-10-18 21:35:27 Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Previous Message Christophe Pettus 2022-10-18 21:31:56 Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP