Is it possible to have an alert when a row is added to a table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 06:41 AM
I currently have a table that periodically adds rows in (sometimes daily, sometimes over a month). I was hoping to have an alert for when a row is added into this. The table has date fields of when rows are loaded in.
I have an alert working, but it just runs and prints the table every day. I was hoping I could do this so that I would only get an email alert if there is a new row.
Any ideas?
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 10:58 AM
You could set your alert with query as:
-- Custom alert to monitor for new rows added to a table
SELECT COUNT(*) AS new_rows
FROM your_table
WHERE event_time > current_timestamp() - interval '1' hour
In this example, the query checks for rows added to your_table within the last hour. If the query returns a non-zero count, the alert will be triggered.