A friend and I figured out what to call Bernardo Damele sys_eval UDF, but the solution is not as elegant as we would like. Here's what we did:
- Since we use Windows, we had to compile the UDF library for Windows using Roland Bouman instructions and install them on our MySQL server.
- We created a stored procedure that calls sys_eval.
- We created a trigger that calls a stored procedure.
Saved procedure code:
DELIMITER $$ CREATE PROCEDURE udfwrapper_sp (p1 DOUBLE, p2 DOUBLE, p3 BIGINT) BEGIN DECLARE cmd CHAR(255); DECLARE result CHAR(255); SET cmd = CONCAT('C:/xampp/php/php.exe -f "C:/xampp/htdocs/phpFile.php" ', p1, ' ', p2, ' ', p3); SET result = sys_eval(cmd); END$$;
Launch Code:
CREATE TRIGGER udfwrapper_trigger AFTER INSERT ON sometable FOR EACH ROW CALL udfwrapper_sp(NEW.Column1, NEW.Column2, NEW.Column3);
I am not happy with the availability of the stored procedure, and I do not know if it creates additional overhead, but it really works. Each time a line is added to sometable, a trigger fires.
Mike E. May 04 '10 at 6:26 a.m. 2010-05-04 06:26
source share