MySQL version: 5.1.73 Database client version: libmysql - 5.1.73
I'm trying to check if NEW.src exists in the last one hour and if it doesn't then execute sys_exec udf.
I have the following trigger in mysql. As this is an after insert trigger my IF condition will check if there is only one value in the last one hour and then proceed with the sys_exec statement.
BEGIN
SET @numofcalls = (SELECT count(src) FROM `cdr` WHERE calldate >= DATE_SUB(NOW(),INTERVAL 1 HOUR) AND src = NEW.src);
IF (numofcalls = 1) then
SET @missed_call = sys_exec(CONCAT('/usr/bin/php /var/lib/asterisk/agi-bin/api_pbx/call_api.php ', NEW.src));
END IF;
END
I get no syntax error when saving the trigger. When a new record is inserted the sys_exec statement doesn't seem to run and exits from the IF condition.
Can someone please suggest what I'm doing wrong here.