2024-04-16 15:01:14 +00:00
|
|
|
DELIMITER $$
|
2024-05-03 12:03:26 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRiskProblem`(
|
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
|
|
|
|
SELECT vSelf ticketFk, vRisk hasProblem;
|
|
|
|
|
|
|
|
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 ;
|