Re: Need help with trigger

2021-01-24 Thread Condor
On 23-01-2021 23:29, Melvin Davidson wrote: Maybe this example will help. From https://www.postgresql.org/docs/current/sql-insert.html INSERT INTO distributors AS d (did, dname) VALUES (8, 'Anvil Distribution') ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname || ' (formerly ' ||

Re: Need help with trigger

2021-01-23 Thread Melvin Davidson
Maybe this example will help. >From https://www.postgresql.org/docs/current/sql-insert.html INSERT INTO distributors AS d (did, dname) VALUES (8, 'Anvil Distribution') ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname || ' (formerly ' || d.dname || ')' WHERE d.zipcode <> '21201';

Re: Need help with trigger

2021-01-23 Thread Adrian Klaver
On 1/23/21 12:14 PM, Condor wrote: On 23-01-2021 20:49, Adrian Klaver wrote: On 1/23/21 10:20 AM, Condor wrote: Sorry, I'm sorry, I don't understand something. You mean to do pure INSERT ON CONFLICT DO or to modify the trigger ? No I meant that in the external program you use to fetch

Re: Need help with trigger

2021-01-23 Thread Condor
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 =

Re: Need help with trigger

2021-01-23 Thread Adrian Klaver
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

Re: Need help with trigger

2021-01-23 Thread Condor
On 23-01-2021 18:31, Adrian Klaver wrote: On 1/23/21 4:57 AM, Condor 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 is the table being read

Re: Need help with trigger

2021-01-23 Thread Condor
On 23-01-2021 18:17, David G. Johnston wrote: On Saturday, January 23, 2021, Condor 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

Re: Need help with trigger

2021-01-23 Thread Adrian Klaver
On 1/23/21 4:57 AM, Condor 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 is the table being read from and is it in the same database? See

Re: Need help with trigger

2021-01-23 Thread David G. Johnston
On Saturday, January 23, 2021, Condor 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 alrea

Need help with trigger

2021-01-23 Thread Condor
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