salix/db/routines/vn/procedures/ticketObservation_addNewBor...

21 lines
623 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketObservation_addNewBorn`(vTicketFk INT)
BEGIN
/**
* Inserta observaciones para los tickets con clientes nuevos o recuperados
*
* @param vTicketFk Identificador de vn.ticket
*/
DECLARE vDescription VARCHAR(20) DEFAULT '¡Cliente NUEVO! ';
INSERT INTO vn.ticketObservation(ticketFk, observationTypeFk, description)
SELECT vTicketFk, ot.id, vDescription
FROM vn.observationType ot
WHERE ot.hasNewBornMessage
ON DUPLICATE KEY UPDATE description = CONCAT(vDescription, ticketObservation.description);
END$$
DELIMITER ;