Hi Ted,

When a new record is added to a specific table, I want to
react to it right away, running a perl script to do something.

Right now, I use a cronjob that checks the table every minuet.
It is slow(it could waits up to a whole min.) and not efficient.

To my understanding, I would need to put a trigger on this table. When the trigger
is triggered, it will call the same perl script through UDF. Not sure
whether I get it right.

Seems like a better approach might be:

* Build a UDF that sends a SIGALRM to your Perl script.
  - You can test this independently by calling it with SELECT.
  - This will mean getting the PID somehow.
  - Likely, the Perl script will need to write its PID somewhere.
  - You'll read the PID in your UDF and call kill(pid, SIGALRM)

* Write your Perl script so that it looks like so:

  while(1) {
    &do_work();
    <check if the while should be broken>
    sleep 60;
  }

* Upon receiving the SIGALRM, the Perl script will be woken up early and get to its work immediately. If something fails for any reason, you go back to the old behaviour of checking every 60 seconds.

Regards,

Jeremy

--
Jeremy Cole
Technical Yahoo - MySQL (Database) Geek
Desk: 408 349 5104

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to