My SQL wrote:[color=blue]
> Hi
>
> Can I trigger an external program to run when a new record is added to
> the mysql table?[/color]
In theory yes, you can write a UDF to do something like this, and call
that UDF from a trigger, but that's not an advisable solution, IMO.
UDF's that try to change state outside the DBMS (e.g. writing files,
starting processes, sending notifications, etc.) are risky. They may
take an unbounded amount of time to execute. Or they may be a security
vulnerability. Or they may have a bug that makes them crash, which
would bring down your MySQL server.
[color=blue]
> The external program is in C and instead of scanning the table
> continuously for new insertions, it will be better if an external
> program could be triggered.[/color]
I think it's better to have another process monitor the data for
changes. If you really have a requirement that this be close to
real-time, you need to do continual scanning.
You might consider defining a special table to store the "flag" data
that a change has occurred, and on which record, etc. Then the external
process monitors only that one table. Once the external process has
accounted for a given change, it deletes the flag from that table.
Perhaps you could use the CSV storage engine to make it easier for that
external process to perform the monitoring without burdening the MySQL
engine.
See
http://dev.mysql.com/doc/refman/5.0/...ge-engine.html
Regards,
Bill K.