Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipbVx-0004LR-KL for pgsql-admin@arkaria.postgresql.org; Thu, 09 Jan 2020 17:22:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipbVv-0007C9-A6 for pgsql-admin@arkaria.postgresql.org; Thu, 09 Jan 2020 17:22:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipbVv-0007By-0j; Thu, 09 Jan 2020 17:22:31 +0000 Received: from imx6.etecsa.cu ([200.55.152.141]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ipbVs-0003tM-5I; Thu, 09 Jan 2020 17:22:30 +0000 Received: from mail.etecsa.cu (unknown [192.168.91.10]) by imx6.etecsa.cu (Postfix) with ESMTP id 8F007D7; Thu, 9 Jan 2020 12:22:25 -0500 (CST) Received: from webmailrc.etecsa.cu (unknown [192.168.97.37]) (Authenticated sender: gilberto.castillo) by mail.etecsa.cu (Postfix) with ESMTPA id 8BAA730088CE; Thu, 9 Jan 2020 12:22:25 -0500 (CST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 09 Jan 2020 12:22:25 -0500 From: gilberto.castillo@etecsa.cu To: Michael Lewis Cc: Pepe TD Vo , Pgsql-admin , pgsql-general@postgresql.org Subject: Re: [MASSMAIL]Re: partitioned table In-Reply-To: References: <148443228.5959267.1578589603211.ref@mail.yahoo.com> <148443228.5959267.1578589603211@mail.yahoo.com> Message-ID: <647a17c086a0ae0490118eec4f5b46d3@etecsa.cu> X-Sender: gilberto.castillo@etecsa.cu User-Agent: Roundcube Webmail/1.2.5 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 149664 [Jan 09 2020] X-KLMS-AntiSpam-Version: 5.8.14.0 X-KLMS-AntiSpam-Envelope-From: gilberto.castillo@etecsa.cu X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Info: LuaCore: 336 336 9396dd2f401bf2feca9da187509bda34e224ee24, {Tracking_content_type, plain}, {Headers: Tracking_Text_ENG_RU_Has_Extended_Latin_Letters, eng}, {Tracking_from_domain_doesnt_match_to}, Auth:dkim=none X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, 1970/01/01 00:00:00 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2020/01/09 10:58:00 #11251582 X-KLMS-AntiVirus-Status: Clean, skipped List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I think you might create a block "Begin-Commit", before procedure call. El 2020-01-09 12:15, Michael Lewis escribió: >> when I manually mocking the data into both tables are fine and when >> I run the procedure, I get errorcode: 42P10 MSG: there is no unique >> or exclusion constraint matching on the CONFLICT specification >> >> the procedure is > > ... > >> INSERT INTO ecisdrdm.bnft_curr_fact AS prod (bnft_fact_id, >> bene_cntry_of_brth_id, bene_cntry_of_rsdc_id, >> bene_cntry_of_ctznshp_id, frm_id, svc_ctr_id, actn_dt_in_id, >> actn_tm_in_id, src_sys_id, >> bnft_hist_actn_id, bene_id, bene_end_dt_id, petnr_app_id, atty_id, >> uscis_emp_id, application_id, >> rmtr_id, prpr_id, mig_filename) >> SELECT stg.bnft_fact_id, stg.bene_cntry_of_brth_id, >> stg.bene_cntry_of_rsdc_id, >> stg.bene_cntry_of_ctznshp_id, stg.frm_id, stg.svc_ctr_id, >> stg.actn_dt_in_id, stg.actn_tm_in_id, stg.src_sys_id, >> stg.bnft_hist_actn_id, stg.bene_id, stg.bene_end_dt_id, >> stg.petnr_app_id, stg.atty_id, stg.uscis_emp_id, stg.application_id, >> >> stg.rmtr_id, stg.prpr_id, stg.mig_filename >> FROM ecisdrdm.stg_bnft_curr_fact stg >> ON CONFLICT ("bnft_fact_id") DO UPDATE >> SET (bnft_fact_id, bene_cntry_of_brth_id, bene_cntry_of_rsdc_id, > > The documentation and the error message explain the issue. > > "there is no unique or exclusion constraint matching on the CONFLICT > specification" > > "The optional ON CONFLICT clause specifies an alternative action to > raising a unique violation or exclusion constraint violation error." > > -https://www.postgresql.org/docs/current/sql-insert.html > > You have an index, but it is not unique. With partitioning, you cannot > create a unique index on a column that is not contained by your > partition key. So, you need to re-write to skip the use of ON CONFLICT > I expect.