salix/db/routines/vn/procedures/sale_setProblemComponentLac...

25 lines
697 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_setProblemComponentLack`(
vSelf INT
)
BEGIN
/**
* Update the problems for sales lines that have or no longer have problems with components,
* verify whether all mandatory components are present or not
*
* @param vSelf Id del sale
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk, isProblemCalcNeeded))
ENGINE = MEMORY
SELECT vSelf saleFk,
sale_hasComponentLack(vSelf) hasProblem,
(ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded
FROM sale
WHERE id = vSelf;
CALL sale_setProblem('hasComponentLack');
DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;