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 1mBzJX-0003ah-5B for pgsql-admin@arkaria.postgresql.org; Fri, 06 Aug 2021 12:51:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mBzJW-0006ob-0a for pgsql-admin@arkaria.postgresql.org; Fri, 06 Aug 2021 12:51:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <066ce286@free.fr>) id 1mBzJV-0006mR-NY for pgsql-admin@lists.postgresql.org; Fri, 06 Aug 2021 12:51:01 +0000 Received: from smtp5-g21.free.fr ([2a01:e0c:1:1599::14]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <066ce286@free.fr>) id 1mBzJT-0002Yo-O7 for pgsql-admin@lists.postgresql.org; Fri, 06 Aug 2021 12:51:01 +0000 Received: from zimbra82-e14.priv.proxad.net (unknown [172.20.243.235]) by smtp5-g21.free.fr (Postfix) with ESMTP id 6D2F55FF96; Fri, 6 Aug 2021 14:50:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1628254257; bh=jnf7SffigPXDuwbGnjXDvZBISJpAXMIwDb3bLPAc4a4=; h=Date:From:To:In-Reply-To:Subject:From; b=jcyxY/BYyKrHAorm4rk73o/puDObEu1ZhlZu15QVBj0h0zb7Iz/I2GPDVAL8Ita3J lPZp+Algq7JrGLE2MZmISTnTJYfKZpkyGizH5XtkPqlBOEUL9dr/27wR2OvNo+8KiZ TWj1MUAd0Q4je1TSTLpY5Y9v5AZNYV5vvHdE+pM4lNjzBhGf1kZWyeAdrmd11bgeai t1rTPLfmW+CfgeX8ZcZFOOdh/YevE00r2WOq/9TY+sgtzaYpM3znAH7rAylzk8yfrM 32V4IV2QN1GijIOK43CgbuZ9axjP8iiN/2u+NuIn4cnypn1AeeFr72pTW4i8zrE2Fu 9Ve7b5k0jV2NQ== Date: Fri, 6 Aug 2021 14:50:57 +0200 (CEST) From: 066ce286@free.fr To: Mukesh Rajpurohit , Pgsql-admin Message-ID: <59272590.782882796.1628254257380.JavaMail.root@zimbra82-e14.priv.proxad.net> In-Reply-To: Subject: Re: Oracle error log table equivalent in postgresql MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [81.252.143.45] X-Mailer: Zimbra 7.2.0-GA2598 (ZimbraWebClient - GC92 (Win)/7.2.0-GA2598) X-Authenticated-User: 066ce286@free.fr List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Thanks, but it solve just part of the problem. In oracle insert > statement executes and rejected rows are inserted in error log table > in same transaction. But, its similar feature or workaround seems > hard in postgresql. It's not hard. You may either intercept the exception( EXCEPTION WHEN OTHER ...) so that the transaction will not be rollbacked, so you can easily insert into another table what you want. But, if you want to rollback the transaction with a RAISE EXCEPTION, you just have to insert in your log table using another transaction, for example with a loopback dblink. Something like : select setting INTO l_port FROM pg_settings WHERE name = 'port'; PERFORM * FROM dblink( FORMAT('dbname=%s user=%s port=%s',current_database(), current_user, l_port), FORMAT('INSERT INTO TRACE_ERROR(ernno,errmsg,errcontext) VALUES (%L,%L,%L);',l_errno,l_errmsg,l_errctx) ) AS p (ret text); Otherwise, when you rollback, the INSERT into the error log table will be also rollbacked.