NOTIFY/LISTEN Using Embedded SQL (ecpg)

From: "Craig Orsinger" <cjorsinger(at)m5(dot)earthlink_net(dot)invalid>
To: pgsql-general(at)postgresql(dot)org
Subject: NOTIFY/LISTEN Using Embedded SQL (ecpg)
Date: 2001-05-22 17:08:31
Message-ID: j2xO6.21984$BN6.885585@newsread1.prod.itd.earthlink.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[cross posted from comp.databases.postgresql.general]

I seem to have painted myself into a corner, technologically speaking.
I am implementing a database using embedded SQL, and PostgreSQL
6.5.3 as the backend. The problem is that I would like to use the NOTIFY
feature, but the only way I've found of doing this from within a C
program is to use the 'PQnotifies()' function, which requires a PGconn
connection its first parameter. ESQL doesn't provide this connection
information as far as I can tell.

So, it appears that I can set up my program to LISTEN or
UNLISTEN using embedded SQL, but I can't get a notification when
it's sent. Or so I think. _Is_ there a way to get the libpq connection info
from the ESQL CONNECT call?

Does anyone have a suggestion (other than completely rewriting
my application in libpq calls)? Pointers to any examples of how
this is done would be especially helpful, but any hints would be
appreciated.

Here's an example that may help illustrate my problem:

int main()
{
PGconn *conn = NULL;

EXEC SQL CONNECT database ;

EXEC SQL LISTEN foo_changed ;

for( ; /* EVER */ ; )
{
if( PQnotifies(conn) ) /* conn is still NULL */
printf("Something happened\n" ) ;

.....
}
}

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Orsinger 2001-05-22 17:50:15 Re: perl vs php for postgresql
Previous Message Bruce Momjian 2001-05-22 16:52:39 Re: Re: ZeroFill(.../pg_xlog/xlogtemp.20148) failed: No such file or directory