Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd8x8-002KTw-LA for pgsql-general@arkaria.postgresql.org; Mon, 04 Sep 2023 12:45:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qd8x7-00BF5u-Am for pgsql-general@arkaria.postgresql.org; Mon, 04 Sep 2023 12:45:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd8x6-00BF5X-Rk for pgsql-general@lists.postgresql.org; Mon, 04 Sep 2023 12:45:12 +0000 Received: from mout-u-107.mailbox.org ([80.241.59.207]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd8x2-002zKo-4m for pgsql-general@lists.postgresql.org; Mon, 04 Sep 2023 12:45:11 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4RfSyk6PRXz9sRG; Mon, 4 Sep 2023 14:45:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1693831503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=weCD+W/yVSzs3G8eVZ0Ijislc7PRwxa/RDMn7SolVHM=; b=aYzzIeDSpKVc2nREPttLwLGoXugpnP6Mioh1pk+3dVizJi+35+ijP/IMfOsy5XW/zXED8l Iv6mthMgwq6vVfO0aMuXfkn8eW6W5XuzJy8LuOUSvml1NeFZCYOD36j4S68mNV2FRdoGl5 zwTYHB7be3xFvkrlrdg706TwfMs2M2s+x/T16Dedn4MjPecBuIWJinVrr0/8tq9SyPRTK/ 8jLb6XaB0jzCHCHDoOsD/ALkmmyT4ro3hDKee3Zss0zGeh5YXAIGjZDWAUPGlulv5IjwfV z3FaHAsvdiQqDGZEwLHEP1ztNVxVXCLSBuPVdOP52ELReO5nvvZPvDxa69tixg== Date: Mon, 4 Sep 2023 14:45:01 +0200 (CEST) From: Erik Wienhold To: Lorusso Domenico , pgsql-general@lists.postgresql.org Message-ID: <1341766181.156278.1693831501720@office.mailbox.org> In-Reply-To: References: Subject: Re: rollback to savepoint issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Rspamd-Queue-Id: 4RfSyk6PRXz9sRG List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 04/09/2023 11:51 CEST Lorusso Domenico wrote: > I can't use the savepoint and rollback to savepoint clause. > I've found some similar problems around on the web, but I can't catch the > good way to proceed. > > What I'm trying to do is: > * compare new set of attribute with older > * if some attributes are part of old set and not in the new one: delete > the old > * but if parameter "on_misisng_delete" is false rollback delete command > and rais exception > The original=C2=A0code in embedded in a function, but the problem is the = same: Transaction control is not possible in functions. Only in procedures (CALL= ) and DO blocks. > ERROR: syntax error at or near "to" > LINE 41: rollback to savepoint deleteAttribute; Use BEGIN ... EXCEPTION ... END instead of manual savepoints. [1] [1] https://www.postgresql.org/docs/current/plpgsql-porting.html#PLPGSQL-PO= RTING-EXCEPTIONS -- Erik