Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okuDX-0006yX-ET for pgsql-general@arkaria.postgresql.org; Tue, 18 Oct 2022 21:33:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1okuDW-0001UH-Cf for pgsql-general@arkaria.postgresql.org; Tue, 18 Oct 2022 21:33:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okuDW-0001U8-2k for pgsql-general@lists.postgresql.org; Tue, 18 Oct 2022 21:33:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okuDT-0006zg-S1 for pgsql-general@lists.postgresql.org; Tue, 18 Oct 2022 21:33:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29ILXbiS2746246; Tue, 18 Oct 2022 17:33:37 -0400 From: Tom Lane To: Bryn Llewellyn cc: Christophe Pettus , Ravi Krishna , pgsql-general list Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP In-reply-to: References: <353091661.109766.1666124045054.ref@mail.yahoo.com> <353091661.109766.1666124045054@mail.yahoo.com> <72BEC008-DC6C-4D80-80A6-E1634CFFA656@thebuild.com> Comments: In-reply-to Bryn Llewellyn message dated "Tue, 18 Oct 2022 14:15:20 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2746244.1666128817.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 18 Oct 2022 17:33:37 -0400 Message-ID: <2746245.1666128817@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bryn Llewellyn writes: > xof@thebuild.com wrote: >> You can commit in a loop, but not in BEGIN / END block that has an exce= ption 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