I have a mySQL database where I need to check the most recent day in a table and call a procedure if a day has passed. So I tried this code:
DECLARE mDay DATE;
SELECT `date` INTO mDay
FROM TimeTable ORDER BY `date` DESC
LIMIT 1;
IF(mDay = NULL OR mDay != DATE(CURRENT_TIMESTAMP)) THEN
CALL UpdateTimeTable()
END IF;
(In my current test case the TimeTable is empty.)
But the procedure never gets called, so I tried changing the condition to: mDay = NULL OR mDay != NULL
, and it still didn't get called. Then I tried mDay = DATE(CURRENT_TIMESTAMP) OR mDay != DATE(CURRENT_TIMESTAMP)
and it still didn't get called.
Finally I changed it to simply true
and then it calls the procedure.
What's going wrong here?