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