salix/db/routines/vn/procedures/ticket_setProblemTaxDataChe...

25 lines
658 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`tticket_setProblemTaxDataCheckedByClient`(
vClientFk INT
)
proc: BEGIN
/**
* Update the problem of tickets for a specific client, depending on whether
* the client taxDataCheched is verified or not
*
* @param vClientFk Id cliente
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk))
ENGINE = MEMORY
SELECT t.id ticketFk, FALSE hasProblem
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.shipped >= util.midnight()
AND c.id = vClientFk;
CALL ticket_getTaxDataCheckedProblem();
DROP TEMPORARY TABLE tmp.ticket;
END$$
DELIMITER ;