Trigger Script on PostgreSQL Notification

I’m looking for a way to trigger the execution of a script via a database notification.Currently my company is using a custom application that sends out reports when a database notification occurs. We are looking to move this feature into Ignition so that we can take advantage of its reporting capabilities. Is it possible to emulate this behavior in Ignition?

You want your database to be what triggers the execution of a result? How does it work now? I am assuming your current setup is just polling the database and looking for a change in some value? If so that would be pretty easily replicated in Ignition.

We are using PostgreSQL notifications and listening for a change (info about that can be found here). While the application we are currently using is essentially polling the database on a regular basis, to detect changes you have to first subscribe to the notification LISTEN my_trigger;. Once triggered you receive a payload (in our use this payload holds the datetime when the shift ended). This is then used to query the necessary data to generate the report. While I see that it is possible to run scripts based on a timer I fail to see how something like this would work. I could write some more complicated logic to detect the change on the table manually but wanted to avoid this if possible.

Ignition does not expose implementation details of the various JDBC drivers it supports, mainly because of its use of connection pooling. While you could submit the query to start listening, you couldn’t receive the notifications.

For such a simple use case, just use a scheduled timer event or a scheduled report.

2 Likes

Thanks for the answer. That was the information I was looking for.