26 lines
682 B
MySQL
26 lines
682 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemItemCost`(
|
||
|
vItemFk INT
|
||
|
)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Actualiza los problemas cuando el ticket es demasiado pequeño o deja de serlo, que derivan
|
||
|
* del cambio en la tabla vn.itemCost
|
||
|
*
|
||
|
* @param vItemFk Id del item
|
||
|
*/
|
||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||
|
(INDEX(ticketFk))
|
||
|
ENGINE = MEMORY
|
||
|
SELECT t.id ticketFk, ticket_isTooLittle(t.id) hasProblem
|
||
|
FROM ticket t
|
||
|
JOIN sale s ON s.ticketFk = t.id
|
||
|
WHERE s.itemFk = vItemFk
|
||
|
AND t.shipped >= util.midnight()
|
||
|
GROUP BY t.id;
|
||
|
|
||
|
CALL ticket_setProblem('isTooLittle');
|
||
|
|
||
|
DROP TEMPORARY TABLE tmp.ticket;
|
||
|
END$$
|
||
|
DELIMITER ;
|