Merge pull request 'refactor: refs #7680 Added cursors' (!2723) from 7680-saleTicketSetProblem into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2723 Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
commit
b1290a539b
|
@ -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,
|
||||
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 , '')));
|
||||
REPLACE(problem, vProblemCode , '')))
|
||||
WHERE id = vTicketFk;
|
||||
END LOOP;
|
||||
CLOSE vTicketList;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue