I'm trying out ECPG for work as we plan to switch from Ingres to Postgres. We have multiple C applications that uses DBEVENTs from the database to trigger different actions.
Now I want to use the Postgres function LISTEN to subscribe to events from the database. And I don't know how to use it.
I understand that I can use the LISTEN function to subscribe to a specific channel from the database, but I can't find any explanation on how to actually catch the information and use it in C.
EXEC SQL CONNECT TO :dbname USER postgres;
EXEC SQL LISTEN listener;
for(;;) {
//How do I catch when something happen here and print or save it?
}
If it's not possible with ECPG, is there another way to accomplish this in C?