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 1oku9L-0006Zj-Vs for pgsql-general@arkaria.postgresql.org; Tue, 18 Oct 2022 21:29:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oku9K-0001me-Q4 for pgsql-general@arkaria.postgresql.org; Tue, 18 Oct 2022 21:29:22 +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 1oku9K-0001mR-5U for pgsql-general@lists.postgresql.org; Tue, 18 Oct 2022 21:29:22 +0000 Received: from sonic302-17.consmr.mail.bf2.yahoo.com ([74.6.135.56]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oku9C-0006yC-Jz for pgsql-general@lists.postgresql.org; Tue, 18 Oct 2022 21:29:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1666128552; bh=d8L+mOG6csSU2ozUBeK4eUxwRtrPZP0Ti15JSLwShCM=; h=From:Date:Subject:To:Cc:In-Reply-To:References:From:Subject:Reply-To; b=IbCoMVcDTQdLXXc4EJyNolN36EpMl1HjIQAtsBuwvquoDB2Vmdb+yVCtzSU/Nfbov7U3vV9n8ixAHETHeSauY+SLcUieLJKKMsuTVNlxak0gPxz6YUGS3Xqb5kvA7kb65AmEP5pU78cZGVfDhHBnIHASUFVcr6gl+FtVHrlrcX1h0qDaWxoIPMHtrrcus64v63XQ8Hur+uKJYyaxxKW1Jy16ZGxWgbUjKhy646UqMjnelu/2gT3tgbINt3PZKdX3hTGtTptwbkcM+sKYvE/UpiyGbB7tuqZFpPI9xXAvqxXRfx+cM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kUmiw.1nakvNqDxXS_FYqChHSiCg.CrSRbs8uvtWe4yShwPhzT_VIxua9gQlELcCbGGx. zzuEfz7Q.u9ebwfCVTPXwZyp5v6tykxnUm9hoe1H8gyqa2.KUr3ZIBd7WWhDnQAqOss6QNNwpk32 aWAEa54eEGQgVGMavh7fIZMRP2KtonxcQCJ07isQdUTjFQrR2xFfZk6leNgk7Te.4LWv4xjcx.80 jZ2hvSj6rsOqExFjOCkHLxSxuwqjO0NAvPnPnLxLLn3AoJgQY0.mBkwWWsvq4T6HY3omdgIQz2zh .bbCbrBM7mtBd8dVttdo2ErPyXkurzk2uRwPxhH8v5IEXjdjI6g7hQIoXRuj4cGUrewdAzsTgviX fUkVyjh_vszecfTq.6zUYtHHRJpIQG8GYehB40MZ_63BwlPmVOkVMj..XXxIlaTFMm9S9DwFgJHR gkWL1GduCdaoh6ntl9HFjwAoc5HV.JLwQjvf05ybRrvSDRz0gN.vX1Utpzg4_REjaNvsKisDDB.U ANlsvk.TBhBtwZT9fBr95Uvvt4Hu9njaX_yHe_pqJLF_BryjFK4U2..rSzJRz8uyumXDq2AC.Z99 iNl2rENa_EVW85wdelc_cj6PysPyYNPcjqC1ciFdl4m0jhD4zztLO34RddVIXyM0LrUvxcEyQjv1 ST305uGNUFVuUk9jc0RSCdAUqCu4MBgw- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.bf2.yahoo.com with HTTP; Tue, 18 Oct 2022 21:29:12 +0000 Received: by hermes--production-bf1-64dccd5d47-d2fhz (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 6461efc31ebff8ba8b3a42a0bed1b2fe; Tue, 18 Oct 2022 21:29:11 +0000 (UTC) From: Ravi Krishna Date: Tue, 18 Oct 2022 17:29:11 -0400 Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP Message-Id: Sender: Ravi Krishna To: xof@thebuild.com Cc: "pgsql-general@lists.postgresql.org" In-Reply-To: <72BEC008-DC6C-4D80-80A6-E1634CFFA656@thebuild.com> References: <353091661.109766.1666124045054.ref@mail.yahoo.com> <353091661.109766.1666124045054@mail.yahoo.com> <72BEC008-DC6C-4D80-80A6-E1634CFFA656@thebuild.com> Content-Type: multipart/alternative; boundary="=-1sWcoJsc8ZD63qEGkTyH6A==" MIME-Version: 1.0 X-Mailer: WebService/1.1.20754 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Content-Length: 2822 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-1sWcoJsc8ZD63qEGkTyH6A== Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > 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. The reason I have to deal with error exception is that I want to ignore failure on a table and move on to next table.  I thought I can trick it by moving the part of the code which executes dynamic sql and has exception handler in it,to a separate procedure.  This way I can keep the main procedure without exception handler.  It failed too withthe same error.  So that means this restriction is not at lexical level, but at execution level.This is so disappointing.  It seems there is no way I can copy each table and commit it individually and also capture error. --=-1sWcoJsc8ZD63qEGkTyH6A== Content-Type: text/html; charset=utf-8 Content-Id: Content-Transfer-Encoding: quoted-printable
> You can commit in a loop, but not in= BEGIN / END block that has an exception handler:
> that creat= es a subtransaction for the duration of the BEGIN / END.

The reason I have to deal with error exception is that I w= ant to ignore failure on a table and move on to next table. 

I thought I can trick it by moving the part of the c= ode which executes dynamic sql and has exception handler in it,
t= o a separate procedure.  This way I can keep the main procedure withou= t exception handler.  It failed too with
the same error. &nb= sp;So that means this restriction is not at lexical level, but at execution= level.
This is so disappointing.  It seems there is no way = I can copy each table and commit it individually and also capture error.

= --=-1sWcoJsc8ZD63qEGkTyH6A==--