Subject | Re: Call external program with trigger |
---|---|
Author | mspencewasunavailable |
Post date | 2008-05-12T15:17:06Z |
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@...> wrote:
Consider using Events for this, instead. The external program
you're targeting starts, registers the fact that it wants to be
notified of particular named events and waits for a Firebird Event
to be signalled. When it is notified that the Event has occured, it
does whatever it's supposed to do, then waits again. This program
has to run all the time, of course but it's not doing anything
except waiting until the event occurs.
In the trigger, whenever you want the external program to proceed,
you say POST_EVENT <event name>;
Any worms that exist will be much smaller...
Michael D. Spence
Mockingbird Data Systems, Inc.
>couldn't
> --- In firebird-support@yahoogroups.com, Jocelyn Bernier
> <jbernier@> wrote:
> >
> > I know this must have been a question asked many times but
> findlightweight
> > the answer on the net. I would like to know if it is possible to
> call an
> > external program with trigger ?
>
> Yes it is possible, but it is usually a bad idea.
>
> An external function can be written in your language of choice and
> compiled to a .dll or .so file. These functions should be
> and must be threadsafe. You can declare them in your database,after
> which time you can call them from normal queries or PSQL (triggersor
> procedures).call
>
> There is no technical reason that an external function could not
> an appropriate API call on the host OS to launch a process, but itis
> a can of worms IMO. You need to consider resources and performance.And those are very big worms, indeed.
> You need to consider stability. You need to consider security. You
> need to realise this is using a feature in a way that is normally
> discouraged and therefore understand it may change in the future.
>
> Adam
>
Consider using Events for this, instead. The external program
you're targeting starts, registers the fact that it wants to be
notified of particular named events and waits for a Firebird Event
to be signalled. When it is notified that the Event has occured, it
does whatever it's supposed to do, then waits again. This program
has to run all the time, of course but it's not doing anything
except waiting until the event occurs.
In the trigger, whenever you want the external program to proceed,
you say POST_EVENT <event name>;
Any worms that exist will be much smaller...
Michael D. Spence
Mockingbird Data Systems, Inc.