7729-devToTest_2430 #2739
|
@ -5,14 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
|
|||
BEGIN
|
||||
/**
|
||||
* Update column sale.problem with a problem code
|
||||
*
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.sale(saleFk, hasProblem)
|
||||
*/
|
||||
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 , '')));
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vHasProblem INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vSaleList;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vSaleList INTO vSaleFk, vHasProblem;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
UPDATE sale
|
||||
SET problem = CONCAT(
|
||||
IF(vHasProblem,
|
||||
CONCAT(problem, ',', vProblemCode),
|
||||
REPLACE(problem, vProblemCode , '')))
|
||||
WHERE id = vSaleFk;
|
||||
END LOOP;
|
||||
CLOSE vSaleList;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -9,11 +9,28 @@ BEGIN
|
|||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.ticket(ticketFk, hasProblem)
|
||||
*/
|
||||
UPDATE ticket t
|
||||
JOIN tmp.ticket tt ON tt.ticketFk = t.id
|
||||
SET t.problem = CONCAT(
|
||||
IF(tt.hasProblem,
|
||||
CONCAT(problem, ',', vProblemCode),
|
||||
REPLACE(problem, vProblemCode , '')));
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vHasProblem INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
OPEN vTicketList;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH vTicketList INTO vTicketFk, vHasProblem;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
UPDATE ticket
|
||||
SET problem = CONCAT(
|
||||
IF(vHasProblem,
|
||||
CONCAT(problem, ',', vProblemCode),
|
||||
REPLACE(problem, vProblemCode , '')))
|
||||
WHERE id = vTicketFk;
|
||||
END LOOP;
|
||||
CLOSE vTicketList;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue