Re: Alarm function in PL/pgSQL

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: Jon Smark <jon(dot)smark(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Alarm function in PL/pgSQL
Date: 2011-07-18 22:47:18
Message-ID: 4E24B7F6.605@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jon Smark wrote:
>> I don't think this is really possible with postgres PLs generally.
>> Typically what you have to do is have a function that is called on an
>> interval that checks for alarms and runs them.
>
> Thanks for the prompt reply. Just to clarify: you are saying that the
> function that is called with a given periodicity must be so from *outside*
> PG, ie, from the client application, right? I mean, there is no way
> strictly internal to PG to have a function be called every given number
> of seconds?

You should lookup Postgres' LISTEN and NOTIFY feature, and see if that is useful
in doing what you want. For example, if this is possible, have a
database-transaction-external task running which is LISTENing for your state
setting signal, and then it waits for an hour and then calls the function. Your
first function would send the NOTIFY signal. -- Darren Duncan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-07-18 23:54:25 Re: How to sum monetary variables
Previous Message Jon Smark 2011-07-18 22:35:39 Re: Alarm function in PL/pgSQL