Re: ON INSERT => execute AWK/SH/EXE?

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ON INSERT => execute AWK/SH/EXE?
Date: 2007-09-19 21:51:19
Message-ID: 60d4we2ujs.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-novice

bima(dot)djaloeis(dot)uni(at)googlemail(dot)com ("Bima Djaloeis") writes:
> Hi there,
> I am new to PostgreSQL, is it possible to create something so that
> 1) If I insert / update / delete an item from my DB...
> 2) ... an awk / shell / external program is executed in my UNIX System?
> If yes, how do I do this and if no, thanks for telling.
> Thanks for reading, any help is appreciated.

I Would Not try to do that directly, as that could lead to arbitrary
numbers of processes getting scheduled, which could cause Plenty O
Heartburn.

I would instead suggest having a trigger in place that would, upon
doing this:

a) Insert an ID, if needed, into a work queue table.
(This may be optional.)

b) Use NOTIFY to tell a process that uses LISTEN to wake up and
do whatever work is necessary, possibly processing *multiple*
items.

The LISTENING process needs to be prepared to process all the
queued-up work; that should lead to *vastly* more efficient processing
than spawning a worker for each item.
--
"cbbrowne","@","acm.org"
http://www3.sympatico.ca/cbbrowne/rdbms.html
Rules of the Evil Overlord #60. "My five-year-old child advisor will
also be asked to decipher any code I am thinking of using. If he
breaks the code in under 30 seconds, it will not be used. Note: this
also applies to passwords." <http://www.eviloverlord.com/>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Filip Rembiałkowski 2007-09-19 22:35:58 Re: Configuration starting point...
Previous Message johnf 2007-09-19 21:20:15 Re: Building Windows fat clients

Browse pgsql-novice by date

  From Date Subject
Next Message Sandeep Agarwal 2007-09-20 11:26:46 Re: Null records in pg_operator
Previous Message Oliver Elphick 2007-09-19 21:11:45 Re: copy commands and linefeeds