Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fo7TK-0005Vm-Up for pgsql-general@arkaria.postgresql.org; Fri, 10 Aug 2018 13:28:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fo7TJ-0004CE-3d for pgsql-general@arkaria.postgresql.org; Fri, 10 Aug 2018 13:28:53 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fo7TD-0003j3-Oc for pgsql-general@lists.postgresql.org; Fri, 10 Aug 2018 13:28:49 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fo7T0-00074Y-7x for pgsql-general@lists.postgresql.org; Fri, 10 Aug 2018 13:28:46 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9681F21BD9; Fri, 10 Aug 2018 09:28:31 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 10 Aug 2018 09:28:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=aGqH470JJGx9L5lVbiswkN5f0jvT9 BC+pp7vGgS+boo=; b=cc0LxegnwW8xWPB5zNe6yK65pGimEOpJTrjqSHyc57MeY 69ct7IzHH/ou2vjCFM+ulYBSIphRWPqy0fydxFDyiEqM9nR0zPJ6LS+4e39TLmzR Z3VSX7/nM+OGWfzJLUQhsp1e/+xC6LmaTZs0dZ2RyS51Y/W6A98k8+KKGONK4vSn xYLwkB4aCTw2I2XFQTFypbT1ahcVGZSgwstBs9O0Hc+EuwyV5/mC9PRFqCJUyTAq XyLhwmK6M0IpkoQhL0K8l15MTaS7AxvEFsp7hN1wIKQjWMtyUKLri4ch3R7bzKtS US8XOSaFv0DT/t2gKGDShKCPLYS1FHPccz0FVkdJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=aGqH47 0JJGx9L5lVbiswkN5f0jvT9BC+pp7vGgS+boo=; b=da3tRQysn0oCTjYBauTn+o LoSyralA9wsorDSyDzwoWdd0prf9aaKRBfBktpTZsxRHQhIebBFwzxNwJv/5Fd6E FiUaSmmQEa7pchu95EvL3rx6GThKY4p6buYAIvxVq9/3LW5lASoRGZiGEydkJ8dD QNoT3S3qv2M77/8lov2sTtyUNj0J6LTenTtHHVeo+fJtUejlJU1izVcKBbEGAkrX BMLNOl3c4wsCvgjEvdLWjKkIOqOWLOz6QZ0GZx0uGijUiYDPU9e8EQFT3/w5Zm0j +QFijEdUesks/f1RhHNYgYKitqgXs2c3lM0S2IWtXqeSTefBxe38GwW+6IJL2QyQ == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 09344E462B; Fri, 10 Aug 2018 09:28:30 -0400 (EDT) Subject: Re: multiple conflict targets To: =?UTF-8?Q?Torsten_F=c3=b6rtsch?= , pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <5894f679-804e-379d-cc49-03936f54af9e@aklaver.com> Date: Fri, 10 Aug 2018 06:28:30 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/10/2018 03:12 AM, Torsten Förtsch wrote: > Hi, > > if I read https://www.postgresql.org/docs/9.6/static/sql-insert.html > correctly there can be only one conflict target or none at all. > > What if I have a table with 3 unique constraints? If the first one is > violated by the insert I want to do nothing. If the 2nd is violated some > fields should be updated. And violation of the 3rd one should raise an > error. > > Can that be expressed? Yes as a trigger and associated function. > > Thanks, > Torsten -- Adrian Klaver adrian.klaver@aklaver.com