2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-13 07:54:27 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRisk`(
|
2024-04-16 15:01:14 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-05-02 16:13:12 +00:00
|
|
|
* Update the risk problem for a specific ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
*
|
2024-05-02 16:13:12 +00:00
|
|
|
* @param vSelf Id ticket
|
2024-04-16 15:01:14 +00:00
|
|
|
*/
|
|
|
|
DECLARE vHasRisk BOOL;
|
|
|
|
DECLARE vHasHighRisk BOOL;
|
|
|
|
|
|
|
|
SELECT t.risk > (c.credit + 10), ((t.risk - cc.riskTolerance) > (c.credit + 10))
|
|
|
|
INTO vHasRisk, vHasHighRisk
|
|
|
|
FROM client c
|
|
|
|
JOIN ticket t ON t.clientFk = c.id
|
|
|
|
JOIN clientConfig cc
|
|
|
|
WHERE t.id = vSelf;
|
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-05-22 12:50:45 +00:00
|
|
|
SELECT vSelf ticketFk, vHasRisk hasProblem;
|
2024-04-16 15:01:14 +00:00
|
|
|
|
|
|
|
CALL ticket_setProblem('hasRisk');
|
|
|
|
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
|
|
|
SELECT vSelf ticketFk, vHasHighRisk hasProblem;
|
|
|
|
|
|
|
|
CALL ticket_setProblem('hasHighRisk');
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|