1

My C++ application has to receive alerts from the PostgreSQL database, as soon as any data is modified in tables. Can you please advice to implement this in best possible way.

Please note that alert information would also need to have the information of the data that has been changed.

Thanks, Gtk

2 Answers 2

1

Write a regular pl/pgSQL trigger that sends a NOTIFY when something changes

In your program you can use LISTEN to receive the messages.

The only drawback is, that you need to poll from within your application in regular intervals in order to receive the messages

In 8.x the message sent around could not carry any payload. In 9.0 you can send additional information with the message.

Sign up to request clarification or add additional context in comments.

1 Comment

I would recommend not relying on the payload though. Anyone can send a notification with arbitrary payload. The data really should come from the table.
0

I would write C triggers to receive change information.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.