From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Execute Shell script after insert |
Date: | 2008-10-27 18:54:54 |
Message-ID: | 20081027185453.GQ2459@frubble.xen.chris-lamb.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Oct 27, 2008 at 03:09:31PM -0300, Anderson dos Santos Donda wrote:
> Is there a way to execute a simple shell script in server after execute
> INSERT INTO ?
Yes; as other people have said most of the procedural languages allow
you to run code outside PG. You'd just need to hook this procedure up
to a trigger inside postgres that ran when data was inserted.
As a rule, though, I'd tend not to do this. The rationale being,
when something goes wrong (as code inevitably does) the database
will continue doing things automatically for you (like touching the
filesystem) when you're fighting against it trying to fix things. I'd
be more tempted to write a stored procedure that inserted something
into a table and did the fiddling with the outside world. That way you
can still write normal INSERT statements to fix up the database and not
worry about your triggers trying to be helpful. I'd expect to stop
normal users from being able to INSERT data into the table, thus forcing
them (or, more accurately, the code running on their behalf) to use the
stored procedure.
Sam
From | Date | Subject | |
---|---|---|---|
Next Message | Sam Mason | 2008-10-27 19:16:34 | Re: empty table explain... |
Previous Message | Andreas Jochem | 2008-10-27 18:38:22 | Re: Execute Shell script after insert |