Re: upsert and update filtering

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: armand pirvu <armand(dot)pirvu(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: upsert and update filtering
Date: 2017-07-31 21:31:30
Message-ID: 20170731213130.GA25306@marmot
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

armand pirvu <armand(dot)pirvu(at)gmail(dot)com> wrote:
>But what if in the conflict situation I want to performa the update ONLY if the record is different. The update seems to happen no matter what
>In other words is there anyway I can filter the update to happen (based on the sample date) only for 112 since col2 is different ?

That's quite possible. An ON CONFLICT's UPDATE accepts a WHERE clause,
which can reference both existing and excluded tuples. That WHERE clause
can back out of the UPDATE based on whatever criteria you like.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message armand pirvu 2017-07-31 21:45:24 Re: upsert and update filtering
Previous Message armand pirvu 2017-07-31 21:26:34 upsert and update filtering