I want to create a trigger so that when a field is updated it kicks off a local bash script (or python...whatever) to kick off a workflow (emails, work requests, etc). Is it possible to execute local system scripts/executables from mysql SQL? My google searches have been unsuccessful.
2 Answers
It seems not easy to do it. I think it will be better to do it at the application level if at all possible. You can also query your table for updated rows every x minutes and then execute the script in a cron job.
-
To recognize the updated rows easily, you can add a new column
updated
that should be set to 1 to indicate the updated rows. A trigger after update will set this flag to 1 and your script will clear it.– KhaledFeb 27, 2012 at 15:44 -
As already suggested, a once-per-minute cron job that queries a table with pending tasks is the better solution here.
You won't be calling potentially privileged OS code from a database server, and the control over task execution remains firmly in the hands of your application(s).