Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGVtV-00071T-VZ for pgsql-sql@arkaria.postgresql.org; Wed, 28 Jan 2015 16:55:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YGVtV-0003T4-Br for pgsql-sql@arkaria.postgresql.org; Wed, 28 Jan 2015 16:55:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YGVtU-0003SC-Bf for pgsql-sql@postgresql.org; Wed, 28 Jan 2015 16:55:08 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YGVtP-0006Se-0p for pgsql-sql@postgresql.org; Wed, 28 Jan 2015 16:55:07 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 3D42312090CA for ; Wed, 28 Jan 2015 08:55:02 -0800 (PST) Date: Wed, 28 Jan 2015 09:55:00 -0700 (MST) From: David G Johnston To: pgsql-sql@postgresql.org Message-ID: <1422464100577-5835803.post@n5.nabble.com> In-Reply-To: <1422445747001-5835771.post@n5.nabble.com> References: <1422445747001-5835771.post@n5.nabble.com> Subject: Re: How to insert in a table the error returns by query MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org ciamblex wrote > I need to save in a table the error code (SQLSTATE) and the error message > (SQLERRM) returned by an insert or an update. My procedure must execute an > insert, and if an error occurs, it must be saved into an apposite table. > > But the problem is that if I use the EXCEPTION BLOCK, when an error occurs > the transaction is aborted and any command after cannot be execute. > > How can I save the error returned by a query in a table, using PLPGSQL??? > > Thanks The typical solution seems to be to use dblink to open an independent session that is not affected by rollback when the main session cronks. I'm not sure if FDWs work for this purpose... David J. -- View this message in context: http://postgresql.nabble.com/How-to-insert-in-a-table-the-error-returns-by-query-tp5835771p5835803.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql