feat: refs #7207 add transaction
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-10-04 16:48:38 +02:00
parent 6fcd883f4b
commit e0d0b66963
1 changed files with 10 additions and 4 deletions

View File

@ -11,14 +11,18 @@ BEGIN
*/
DECLARE vNewQueue VARCHAR(10);
DECLARE vExtension VARCHAR(10);
DECLARE vPrevQueue VARCHAR(10);
DECLARE exit handler FOR SQLEXCEPTION
BEGIN
ROLLBACK;
END;
SELECT d.pbxQueue, s.extension, qm.queue
INTO vNewQueue, vExtension, vPrevQueue
START TRANSACTION;
SELECT d.pbxQueue, s.extension
INTO vNewQueue, vExtension
FROM business b
JOIN department d ON d.id = b.departmentFk
JOIN pbx.sip s ON s.user_id = b.workerFk
LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension
WHERE b.id = vBusinessFk;
DELETE FROM pbx.queueMember
@ -26,5 +30,7 @@ BEGIN
INSERT IGNORE INTO pbx.queueMember (queue, extension)
VALUES (vNewQueue, vExtension);
COMMIT;
END$$
DELIMITER ;