X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id C0F8830F134 for ; Tue, 17 Jun 2003 20:34:37 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 77876-08 for ; Tue, 17 Jun 2003 17:34:27 -0300 (ADT) Received: from irko.smoothcorp.com (unknown [208.49.241.41]) by svr1.postgresql.org (Postfix) with ESMTP id BA47230F125 for ; Tue, 17 Jun 2003 17:34:26 -0300 (ADT) Received: from jgardner.ifloor.com ([10.0.1.63]) by irko.smoothcorp.com with esmtp (Exim 4.12) id 19SN9t-0000xL-00; Tue, 17 Jun 2003 13:34:25 -0700 Received: from jgardner.ifloor.com (localhost.localdomain [127.0.0.1]) by jgardner.ifloor.com (8.12.8/8.12.8) with ESMTP id h5HKYQwr008539; Tue, 17 Jun 2003 13:34:26 -0700 Received: from localhost (localhost [[UNIX: localhost]]) by jgardner.ifloor.com (8.12.8/8.12.8/Submit) id h5HKYPuJ008537; Tue, 17 Jun 2003 13:34:25 -0700 From: Jonathan Gardner To: "Anagha Joshi" , Subject: Re: [ADMIN] Notification Date: Tue, 17 Jun 2003 13:34:23 -0700 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200306171334.24931.jgardner@jonathangardner.net> X-SA-Exim-Rcpt-To: ajoshi@nulinkinc.com, pgsql-sql@postgresql.org X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Archive-Number: 200306/206 X-Sequence-Number: 13964 -----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 proce= ss=20 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= =20 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=20 something like: LISTEN customer_19291; Now when someone else goes in and changes the customer info in the database= ,=20 you can have a trigger set up that will NOTIFY. CREATE OR REPLACE FUNCTION notify_on_update() RETURNS TRIGGER AS '=09 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=20 receives the notification, if can update the displayed information. Is this a good starting place? - --=20 Jonathan Gardner (was jgardn@alumni.washington.edu) Live Free, Use Linux! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+73tPWgwF3QvpWNwRAqSQAKC/IsVy45bg4FAy4vwOK0PvBcfbjACg2XWT D98xYLKLXVuQPkUGTiCVHVE=3D =3Dkpg2 -----END PGP SIGNATURE-----