pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Condor <condor@stz-bg.com>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Need help with trigger
Date: Sat, 23 Jan 2021 22:14:09 +0200
Message-ID: <533ed7d44063dca8b45626816aa51cad@stz-bg.com> (raw)
In-Reply-To: <3294def5-09f6-c384-d1fe-f5faf4bcf797@aklaver.com>
References: <6feca05ea1521b0a4da87bfcfe78c39f@stz-bg.com>
	<62244d0f-03d7-6bed-cb7b-722ad32400ad@aklaver.com>
	<84864856b8ac6e5f35f68ace87c44556@stz-bg.com>
	<3294def5-09f6-c384-d1fe-f5faf4bcf797@aklaver.com>

On 23-01-2021 20:49, Adrian Klaver wrote:
> On 1/23/21 10:20 AM, Condor wrote:
>> On 23-01-2021 18:31, Adrian Klaver wrote:
>>> On 1/23/21 4:57 AM, Condor wrote:
>>>> 
>>>> 
> 
>>> 
>>> So do an UPDATE and the RETURN NULL to cancel the INSERT. Untested 
>>> example:
>>> 
>>> UPDATE arhive_table SET sendto = 0, uts = date_part('epoch',
>>> CURRENT_TIMESTAMP)::integer WHERE contract = NEW.contract AND service
>>> = NEW.service;
>>> 
>>> RETURN NULL;
>>> 
>> 
>> 
>> Yep, I think about this update and was my first approach but need to 
>> be done only if end_date is different.
>> If end_date is the same this mean contract still exists so only update 
>> lastseen column, if the lastseen is not updated other process will 
>> read not seen contracts and will generate report and send them to 
>> delete services. If lastseen is changed and sendto is zero again, mean 
>> end_date is changed and need to be send new end_date again to other 
>> systems.
> 
> So add an:
> 
> ELSIF enddate = FROM NEW.end_date THEN
> 
> and do UPDATE of lastseen column.
> 
> Honestly I think this better handled by the external program that
> doing the transformation.
> 
>> 
>> 
>> 


Sorry,

I'm sorry, I don't understand something. You mean to do pure INSERT ON 
CONFLICT DO or to modify the trigger ?





view thread (10+ messages)  latest in thread

Message-ID: <533ed7d44063dca8b45626816aa51cad@stz-bg.com>
Permalink:  ../533ed7d44063dca8b45626816aa51cad@stz-bg.com/
Also on:    postgresql.org/message-id/533ed7d44063dca8b45626816aa51cad@stz-bg.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: condor@stz-bg.com, adrian.klaver@aklaver.com
  Subject: Re: Need help with trigger
  In-Reply-To: <533ed7d44063dca8b45626816aa51cad@stz-bg.com>
  References: <6feca05ea1521b0a4da87bfcfe78c39f@stz-bg.com> <62244d0f-03d7-6bed-cb7b-722ad32400ad@aklaver.com> <84864856b8ac6e5f35f68ace87c44556@stz-bg.com> <3294def5-09f6-c384-d1fe-f5faf4bcf797@aklaver.com> <533ed7d44063dca8b45626816aa51cad@stz-bg.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox