NOTIFY/LISTEN Using Embedded SQL (ecpg)

NOTIFY/LISTEN Using Embedded SQL (ecpg)

Post by Craig Orsinge » Wed, 23 May 2001 10:50:48



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.

 
 
 

NOTIFY/LISTEN Using Embedded SQL (ecpg)

Post by Richard Huxto » Thu, 24 May 2001 18:40:36




Sent: Tuesday, May 22, 2001 6:08 PM
Subject: [GENERAL] NOTIFY/LISTEN Using Embedded SQL (ecpg)

Quote:> [cross posted from comp.databases.postgresql.general]

>      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.

Can you not just wrap up the libpq stuff in it's own module? A "LISTEN X"
doesn't have to be on any particular connection. Don't know whether opening
another connection per program is practical for you.

- Richard Huxton

---------------------------(end of broadcast)---------------------------


 
 
 

NOTIFY/LISTEN Using Embedded SQL (ecpg)

Post by Tom La » Fri, 25 May 2001 04:35:01



>      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?

Seems like there should be, if there isn't.  NOTIFY isn't the only thing
you might want to grab the PGconn object for.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

 
 
 

1. LISTEN/NOTIFY

I'm developing an e-commerce site using Apache/mod_perl and, for
performance, I intend to cache rows such as user and product information
inside Perl. I think the LISTEN/NOTIFY interface would be perfect for
invalidating the cache when a product/user gets updated, yet I have not
found a way to access it from Perl -- DBI, or DBD::Pg even, offer no way
to "listen". Also, I don't really like the vanilla Pg. So, my question
to you is, is there another efficient way to accomplish notification of
updates?

Thank you

Cristv?o

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

2. How to transfer Tablespace from one instance to another

3. SQL statements

4. listen/notify argument (old topic revisited)

5. Database Crisis!!!

6. Synchronous LISTEN/NOTIFY?

7. problem with notify/listen

8. LISTEN/NOTIFY benchmarks?

9. listen/notify argument (old topic revisited)

10. HELP ecpg / postgres / embedded SQL