问题
I want to write a windows service in C# that will wait for a change in the particular table in PostgreSQL database and then operate based on the data from the last inserted row. As far as I know (I'm new to PostgreSQL) I can use triggers to execute a function in structural code - but how to make it pass the data to my service?
Thanks in advance for any suggestions.
回答1:
Look at asynchronous notifications - http://www.postgresql.org/docs/8.4/static/sql-notify.html. Fire off a notification with NOTIFY from inside the trigger, have the service do LISTEN on it's connection and act upon the notification.
来源:https://stackoverflow.com/questions/2147353/how-to-make-postgresql-trigger-and-c-sharp-windows-service-work-together