DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTaxDataChecked`(vSelf INT) BEGIN /** * Update the problem of tickets, depending on whether * the client taxDataCheched is verified or not * * @param vSelf Id ticket, if NULL all tickets */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket (INDEX(ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem FROM ticket t JOIN client c ON c.id = t.clientFk WHERE t.shipped >= util.midnight() AND (c.id = vClientFk OR vClientFk IS NULL); CALL ticket_setProblem('isTaxDataChecked'); DROP TEMPORARY TABLE tmp.ticket; END$$ DELIMITER ;