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

21 lines
629 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`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 ;