7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
2 changed files with 47 additions and 12 deletions
Showing only changes of commit 05202e0b76 - Show all commits

View File

@ -5,14 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
BEGIN BEGIN
/** /**
* Update column sale.problem with a problem code * Update column sale.problem with a problem code
*
* @param vProblemCode Code to set or unset * @param vProblemCode Code to set or unset
* @table tmp.sale(saleFk, hasProblem) * @table tmp.sale(saleFk, hasProblem)
*/ */
UPDATE sale s DECLARE vSaleFk INT;
JOIN tmp.sale ts ON ts.saleFk = s.id DECLARE vHasProblem INT;
SET s.problem = CONCAT( DECLARE vDone BOOL;
IF(ts.hasProblem, DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale;
CONCAT(s.problem, ',', vProblemCode), DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
REPLACE(s.problem, vProblemCode , '')));
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$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -9,11 +9,28 @@ BEGIN
* @param vProblemCode Code to set or unset * @param vProblemCode Code to set or unset
* @table tmp.ticket(ticketFk, hasProblem) * @table tmp.ticket(ticketFk, hasProblem)
*/ */
UPDATE ticket t DECLARE vTicketFk INT;
JOIN tmp.ticket tt ON tt.ticketFk = t.id DECLARE vHasProblem INT;
SET t.problem = CONCAT( DECLARE vDone BOOL;
IF(tt.hasProblem, DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket;
CONCAT(problem, ',', vProblemCode), DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
REPLACE(problem, vProblemCode , '')));
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$$ END$$
DELIMITER ; DELIMITER ;