From: Condor <condor@stz-bg.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Need help with trigger
Date: Sat, 23 Jan 2021 20:09:23 +0200
Message-ID: <7dcfcb8bfaed656fe17dd6c76fe7fb22@stz-bg.com> (raw)
In-Reply-To: <CAKFQuwaGMpHMoVP5Ev9YkqsUdgfLUQ5GbtSzJFPt+4D=2GTXTA@mail.gmail.com>
References: <6feca05ea1521b0a4da87bfcfe78c39f@stz-bg.com>
<CAKFQuwaGMpHMoVP5Ev9YkqsUdgfLUQ5GbtSzJFPt+4D=2GTXTA@mail.gmail.com>
On 23-01-2021 18:17, David G. Johnston wrote:
> On Saturday, January 23, 2021, Condor <condor@stz-bg.com> wrote:
>
>> Hello ppl,
>>
>> I need help with trigger how to replace insert command with update.
>> External program read data from one table and in every 30 min I need
>> to refresh data in arhive table.
>> What I want is: if data already inserted and end_date is not
>> changed, only to update lastseen column. If data not exists to
>> insert data and if data exists and end_date is changed
>> to update end_date, lastseen and sendto columns. Well, update
>> probably will never happened, this functionality is left for
>> frontend but its can be cut off.
>
> Seems like an insert on conflict would be simpler. Otherwise, what is
> your question or concern?
>
> David J.
This was my first approach, but as the sample data I provide, end_date
will always be updated not only if it is changed and my goal is to have
no meaningless records. My question is there a way to update the trigger
instead of inserting.
HS
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, david.g.johnston@gmail.com
Subject: Re: Need help with trigger
In-Reply-To: <7dcfcb8bfaed656fe17dd6c76fe7fb22@stz-bg.com>
References: <6feca05ea1521b0a4da87bfcfe78c39f@stz-bg.com> <CAKFQuwaGMpHMoVP5Ev9YkqsUdgfLUQ5GbtSzJFPt+4D=2GTXTA@mail.gmail.com> <7dcfcb8bfaed656fe17dd6c76fe7fb22@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