如何使PostgreSQL触发和C#Windows服务一起工作?工作、PostgreSQL、Windows

2023-09-04 05:10:03 作者:青春纯属扯淡°

我想写一个Windows服务在C#中,将等待在特定表的变化PostgreSQL数据库,然后根据从最后插入的行中的数据进行操作。 据我所知,(我是新来的Pos​​tgreSQL)我可以使用触发器来执行结构性code函数 - 但是如何让它将数据传递给我的服务?

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.

推荐答案

看异步通知 - 的 http://www.postgresql.org/docs/8.4/static/sql-notify.html 。从触发器内NOTIFY,有服务不侦听它把火关通知的通知后,连接和行为。

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.