17 lines
472 B
SQL
17 lines
472 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
|
|
vProblemCode VARCHAR(25)
|
|
)
|
|
BEGIN
|
|
/**
|
|
* Actualiza en la tabla sale la columna problema
|
|
* @table tmp.sale(saleFk, hasProblem) Identificadores de los sales a actualizar
|
|
*/
|
|
UPDATE sale s
|
|
JOIN tmp.sale ts ON ts.saleFk = s.id
|
|
SET s.problem = CONCAT(
|
|
IF(ts.hasProblem,
|
|
CONCAT(s.problem, ',', vProblemCode),
|
|
REPLACE(s.problem, vProblemCode , '')));
|
|
END$$
|
|
DELIMITER ; |