Re: Best way to use trigger to email a report ? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Best way to use trigger to email a report ?
Date
Msg-id CAKFQuwYfcubMMxgD4QJnBkdCZMUB3=1MZM6_xM5pXaMUi5kFfQ@mail.gmail.com
Whole thread Raw
In response to Best way to use trigger to email a report ?  (David Gauthier <davegauthierpg@gmail.com>)
Responses Re: Best way to use trigger to email a report ?  (Tim Cross <theophilusx@gmail.com>)
List pgsql-general
On Fri, May 8, 2020 at 9:26 AM David Gauthier <davegauthierpg@gmail.com> wrote:
psql (9.6.0, server 11.3) on linux

Looking for ideas.  I want a trigger to...
1) compose an html report based on DB content
2) email the report to a dist list (dl = value of a table column)

If this will involve hybrid coding, I prefer PL/perl.  The linux env has both "mail" and "mutt" (if this is of any help).  

The idea is to send a report to the list when all the data has been collected for a particular job and the final status of the job is updated as a col of a rec of a certain table.  Probably a post update trigger. 

I'd probably limit the trigger to checking for the completion of the data collection and inserting a record into a "email job" table.  Then I'd have cron on a linux machine periodically run a script that queries the "email job" table for work, perform the work, and then either flag the work as done or remove the job record.

David J.

pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Best way to use trigger to email a report ?
Next
From: "David G. Johnston"
Date:
Subject: Re: Thoughts on how to avoid a massive integer update.