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 1pyY5S-0000KB-7i for pgsql-admin@arkaria.postgresql.org; Mon, 15 May 2023 13:18:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pyY5P-0003Vb-RS for pgsql-admin@arkaria.postgresql.org; Mon, 15 May 2023 13:17:59 +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 1pyY5P-0003PO-9Q for pgsql-admin@lists.postgresql.org; Mon, 15 May 2023 13:17:59 +0000 Received: from mailout.easymail.ca ([64.68.200.34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pyY5I-002Sd3-4f for pgsql-admin@lists.postgresql.org; Mon, 15 May 2023 13:17:57 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 2181DEA972; Mon, 15 May 2023 13:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=elevated-dev.com; s=easymail; t=1684156668; bh=mSpBfSqduS1u+KvkBqrXj7Poz5A34NMGNofjPH/wEeE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=S4VBeqNVAEWAspZQgYpCpt6HWaZ/FKMrbPyZULXfOrZL/lvsY8q83sm5yYW4nls6S 8nOt3fZXo45ohUM2i+DEsk1r3Q6HSaoRnjF18mDhoCtdgM+j6ZSi0TTxz0hvtu+9mV G3XDkr0XCYAv0DDanwNayYAg6DKGLKQ8zd7sFUKp657JIbUO/mI+Tt1j/v2O8WZHlr 80IO27pDOgUSOgSxhRK0Up5G2WkvAAPqWrYlsvj2VoEOHpxqX4NG1ySI+6ND9/cig1 8y61Q4imQLSO5Dn2F5GK0/6lvyhc/IAA4ylGhHHkVpLxdhLUM+ZS7dVlk4dpW2nWN1 ymb6cMgWHnRaQ== X-Virus-Scanned: Debian amavisd-new at emo08-pco.easydns.vpn Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo08-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LWQsfmqoPtpA; Mon, 15 May 2023 13:17:47 +0000 (UTC) Received: from smtpclient.apple (unknown [165.140.184.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 8E98BEA963; Mon, 15 May 2023 13:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=elevated-dev.com; s=easymail; t=1684156667; bh=mSpBfSqduS1u+KvkBqrXj7Poz5A34NMGNofjPH/wEeE=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=o3XIvsD0yAew4Dh8PjCD6mWcGWW6EFKr1rrM8NXj4szxikuNQiuty5rFc3Bm7dBy5 HTY1t7n02CBl2nPCUmSOwk/3cUppTiA6mdsDoUvTa0z1HFIjC8+408ni9gi6wQu01o nf6JDGyDG8dzQhv0C15xk2vQYJojyncODZVVu7ryWNkByr9YneK3AunO15yOmCZDhZ XaRwiClrqlHVQXIc+qq8rJZ1vW2Ft6xU05G1Y/XRePg1uEawLVNbek2WxZlF5ekLAR FtykVODhwYKkN8rARfEmkH1DfoasiIweHa1H0F3qLL6aSqVycuTE7ymp0LrfuKRlvr fOlBy1cZnftxg== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: how do I capture conflicting rows From: Scott Ribe In-Reply-To: Date: Mon, 15 May 2023 07:17:36 -0600 Cc: Ron , Pgsql-admin Content-Transfer-Encoding: quoted-printable Message-Id: <36F0306C-E96A-4516-B36E-E97612C95F59@elevated-dev.com> References: <34308ba9-6033-6e57-f44e-500b2ca9cad5@gmail.com> To: Nikhil Ingale X-Mailer: Apple Mail (2.3731.500.231) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On May 15, 2023, at 12:25 AM, Nikhil Ingale = wrote: >=20 > Thing is there is a list of tables (350+ tables) on which I'm running = the insert query i.e., INSERT INTO table ON CONFLICT DO NOTHING to = continue inserting the records by ignoring the conflicting rows. But, at = the same time I would like to capture the conflicting rows or every = single conflicting column (not just the PK's) and their values for every = single table. Create a "staging" table without constraints. Load all rows into it. = Query for conflicts and report to user. Delete conflicting rows. Then = INSERT INTO ... SELECT * FROM ...