How to make PostgreSQL trigger and C# Windows Service work together?

六月ゝ 毕业季﹏ 提交于 2019-12-08 05:28:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!