25 lines
735 B
SQL
25 lines
735 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLackProblemComponent`(
|
|
vComponentFk INT
|
|
)
|
|
BEGIN
|
|
/**
|
|
* Actualiza los problemas para las líneas de ventas que tienen o dejan de tener problemas
|
|
* con los componentes que derivan de cambios en la tabla vn.component
|
|
*
|
|
*/
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
|
(INDEX(saleFk))
|
|
ENGINE = MEMORY
|
|
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem
|
|
FROM ticket t
|
|
JOIN sale s ON s.ticketFk = t.id
|
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
|
WHERE t.shipped >= util.midnight()
|
|
AND sc.componentFk = vComponentFk;
|
|
|
|
CALL sale_setProblem('hasComponentLack');
|
|
|
|
DROP TEMPORARY TABLE tmp.sale;
|
|
END$$
|
|
DELIMITER ; |