Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 13BD463223F for ; Wed, 12 Aug 2009 11:02:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 09619-01 for ; Wed, 12 Aug 2009 14:01:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by mail.postgresql.org (Postfix) with ESMTP id CC97A633362 for ; Wed, 12 Aug 2009 11:01:18 -0300 (ADT) Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtp (Exim 4.62) (envelope-from ) id 1MbEOS-0008EJ-N3; Wed, 12 Aug 2009 08:01:32 -0600 Received: from [208.187.158.94] (helo=[172.16.1.22]) by in02.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1MbEOB-0000Zu-A7; Wed, 12 Aug 2009 08:01:15 -0600 Message-ID: <4A82CB26.3070208@gmail.com> Date: Wed, 12 Aug 2009 08:01:10 -0600 From: Rob Sargent User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 To: Jan Verheyden CC: 'Denis BUCHER' , "'pgsql-sql@postgresql.org'" References: <4A81F244.9070402@hsolutions.ch> <4A821D12.3050500@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-XM-SPF: eid=; ; ; mid=; ; ; hst=in02.mta.xmission.com; ; ; ip=208.187.158.94; ; ; frm=robjsargent@gmail.com; ; ; spf=neutral X-SA-Exim-Connect-IP: 208.187.158.94 X-SA-Exim-Rcpt-To: jan.verheyden@uz.kuleuven.ac.be, dbucherml@hsolutions.ch, pgsql-sql@postgresql.org, robjsargent@gmail.com X-SA-Exim-Mail-From: robjsargent@gmail.com X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Jan Verheyden X-Spam-Relay-Country: Subject: Re: mail alert X-SA-Exim-Version: 4.2.1 (built Thu, 25 Oct 2007 00:26:12 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.327 tagged_above=-10 required=5 tests=AWL=1.272, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/57 X-Sequence-Number: 32966 It looks to me like you want Dennis's #2. Lauch a mailer script from a trigger function. (Function can be any language you're familiar with including pgsql if you wish to take advantage of "\! your-mail-script" Jan Verheyden wrote: > Hi, > > I got a bit stuck... > I was looking for a solution for option a) > > Maybe I'll first explain the situation a bit more: > > I have one database for patient registration > Another one for image storage > And a third one for book keeping > A patient should be registered first before the images are stored, so if there is a new line in the second database with an id which does not exist yet, it has to be notified in the book keeping database. > > Now the questions: > 1) Can I do this with the inner join (tables subject_id from DB1, pat_id from DB2), there it is two different databases > 2) Once it is notified in the book keeping that is not registered yet, is it best to poll on this column to send a warning, or use a trigger?? > > Thanks!! > > > Jan > -----Original Message----- > From: Rob Sargent [mailto:robjsargent@gmail.com] > Sent: Wednesday, August 12, 2009 3:38 AM > To: Denis BUCHER > Cc: Jan Verheyden; 'pgsql-sql@postgresql.org' > Subject: Re: [SQL] mail alert > > Denis BUCHER wrote: > >> Hello, >> >> Jan Verheyden a écrit : >> >> >>> I was looking in what way it’s possible to alert via mail when some >>> conditions are true in a database. >>> >>> >> a) If the alert is not "very urgent" i.e. you can alter some minutes >> later I would do it like this : >> >> 1. Create a function that returns what you need, most importantly if the >> conditions are met >> >> 2. Create a script that does something like "SELECT * FROM function()..." >> >> b) If the email should be sent immediately, you could create a perl >> function in the database, launched by a TRIGGER and launching an >> "external" script... >> >> Therefore, first you have to know the requirements... >> >> Denis >> >> >> > see "check_postgres" for nagios-style monitoring > see \o /tmp/alert_data_file > and \! mailx -s "alert" me@work.com /tmp/alert_data_file > >