Notifications and Triggers

"Observer" base class for trigger notifications. More...
To listen on a database trigger, derive your own class from trigger and define its function call operator to perform whatever action you wish to take when the given trigger arrives. Then create an object of that class and pass it to your connection. DO NOT set triggers directly through SQL, or they won't be restored when a connection fails--and you'll have no way to notice.

Trigger notifications never arrive inside a backend transaction. Therefore, unless you may be using a nontransaction when a notification arrives, you are free to open a transaction of your own inside your trigger's function invocation operator.

Notifications for your trigger may arrive anywhere within libpqxx code, but be aware that PostgreSQL defers notifications occurring inside transactions. (This was done for excellent reasons; just think about what happens if the transaction where you happen to handle an incoming notification is later rolled back for other reasons). So if you're keeping a transaction open, don't expect any of your triggers on the same connection to be notified.

Multiple triggers on the same connection may have the same name. An incoming notification is processed by invoking all triggers (zero or more) of the same name.


Generated on Thu Feb 1 17:12:24 2007 for libpqxx by  doxygen 1.5.1