salix/db/routines/vn/procedures/ticket_getTaxDataCheckedPro...

26 lines
658 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTaxDataCheckedProblem`(
vClientFk INT
)
proc: BEGIN
/**
* Actualiza los problemas de los ticket de hoy y a fututo
* cuyo cliente tenga o no los datos comprobados
*
* @param vClientFk Id del cliente
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk))
ENGINE = MEMORY
SELECT t.id ticketFk, NOT c.isTaxDataChecked hasProblem
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.shipped >= util.midnight()
AND c.id = vClientFk;
CALL ticket_setProblem('isTaxDataChecked');
DROP TEMPORARY TABLE tmp.ticket;
END$$
DELIMITER ;