I am trying to create a trigger in a postgre (9.6) database. My goal is to apped the last inserted row to a file. I can make it work by COPYing the whole table with the following code. My questions are : how to append data with COPY ? and how to use only the last inserted row ? Here is my code.
COPY
create function test_function() returns trigger as $test_trigger$ begin copy (select * from my_table) to 'C:Tempstats.txt'; return NEW; end; $test_trigger$ language plpgsql; create trigger test_trigger after insert on my_table for each row execute procedure test_function();
1.4m articles
1.4m replys
5 comments
57.0k users