pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedNotification
2+ messages / 2 participants
[nested] [flat]
* Notification
@ 2003-06-17 12:13 Anagha Joshi <ajoshi@nulinkinc.com>
2003-06-17 20:34 ` Re: [ADMIN] Notification Jonathan Gardner <jgardner@jonathangardner.net>
0 siblings, 1 reply; 2+ messages in thread
From: Anagha Joshi @ 2003-06-17 12:13 UTC (permalink / raw)
To: pgsql-admin@postgresql.org
Hi All,
I'm new to Postgres. I'm using Postgres-7.2.4
Can anybody guide me in detail how 'NOTIFY-LISTEN' can be implemented
progmatically bet'n frontend and backend?
Help appreciated.
Thx,
Anagha
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [ADMIN] Notification
2003-06-17 12:13 Notification Anagha Joshi <ajoshi@nulinkinc.com>
@ 2003-06-17 20:34 ` Jonathan Gardner <jgardner@jonathangardner.net>
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Gardner @ 2003-06-17 20:34 UTC (permalink / raw)
To: Anagha Joshi <ajoshi@nulinkinc.com>; pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 17 June 2003 05:13, Anagha Joshi wrote:
> Hi All,
> I'm new to Postgres. I'm using Postgres-7.2.4
> Can anybody guide me in detail how 'NOTIFY-LISTEN' can be implemented
> progmatically bet'n frontend and backend?
>
Might want to move this to the SQL list.
The idea is that a process will LISTEN for some notification. Another process
will NOTIFY that notification, and the one listening will get a message.
This is useful for a couple of things.
If you have an app that shows something like customer data, then you might
want to update the customer info when it changes.
Here's the table:
CREATE TABLE customer (
customer_id SERIAL PRIMARY KEY
, first_name VARCHAR(20) NOT NULL
, last_name VARCHAR(20) NOT NULL
);
When displaying the customer info for customer_id 19291, you could do
something like:
LISTEN customer_19291;
Now when someone else goes in and changes the customer info in the database,
you can have a trigger set up that will NOTIFY.
CREATE OR REPLACE FUNCTION notify_on_update() RETURNS TRIGGER AS '
BEGIN
EXECUTE ''NOTIFY ''||TG_RELNAME||''_''||NEW.customer_id;
RETURN NEW;
END
' LANGUAGE 'plpgsql';
CREATE TRIGGER notify_on_update AFTER update ON customer
FOR EACH ROW EXECUTE PROCEDURE notify_on_update();
Now you set up your application to watch for the notification. When it
receives the notification, if can update the displayed information.
Is this a good starting place?
- --
Jonathan Gardner <jgardner@jonathangardner.net>
(was jgardn@alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+73tPWgwF3QvpWNwRAqSQAKC/IsVy45bg4FAy4vwOK0PvBcfbjACg2XWT
D98xYLKLXVuQPkUGTiCVHVE=
=kpg2
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-06-17 20:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-17 12:13 Notification Anagha Joshi <ajoshi@nulinkinc.com>
2003-06-17 20:34 ` Jonathan Gardner <jgardner@jonathangardner.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox