views:

227

answers:

1

Hi,

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.

A: 

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.

Magnus Hagander
This is great - exactly what I needed. It's also easy cause Npgsql (.net data provider for postgresql) supports it :)
kyrisu