This commit is contained in:
parent
5ee78a6b8c
commit
194947dc9a
|
@ -40,7 +40,7 @@ BEGIN
|
|||
|
||||
UPDATE client c
|
||||
JOIN tCreditClients cc ON cc.clientFk = c.clientFk
|
||||
SET Clientes.Credito = newCredit;
|
||||
SET c.credit = newCredit;
|
||||
|
||||
DROP TEMPORARY TABLE tCreditClients;
|
||||
COMMIT;
|
||||
|
|
|
@ -2,11 +2,11 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE)
|
||||
BEGIN
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
||||
CREATE TEMPORARY TABLE tmp.client_list
|
||||
(PRIMARY KEY (Id_Cliente))
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT id Id_Cliente, null grade FROM vn.client;
|
||||
SELECT id clientFk, null grade FROM client;
|
||||
|
||||
CALL client_getDebt (maxRiskDate);
|
||||
|
||||
|
@ -19,11 +19,11 @@ BEGIN
|
|||
c.Id_Pais
|
||||
FROM
|
||||
vn2008.Clientes c
|
||||
JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
|
||||
JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
|
||||
JOIN tmp.risk r ON r.clientFk = c.Id_Cliente
|
||||
JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk
|
||||
GROUP BY c.Id_cliente;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -2,15 +2,18 @@ DELIMITER $$
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`solunionRiskRequest`()
|
||||
BEGIN
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
||||
CREATE TEMPORARY TABLE tmp.client_list
|
||||
(PRIMARY KEY (Id_Cliente))
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
|
||||
SELECT *
|
||||
FROM (SELECT cc.client clientFk, ci.grade
|
||||
FROM vn.creditClassification cc
|
||||
JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
|
||||
WHERE dateEnd IS NULL
|
||||
ORDER BY ci.creationDate DESC
|
||||
LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
|
||||
LIMIT 10000000000000000000) t1
|
||||
GROUP BY clientFk;
|
||||
|
||||
CALL client_getDebt (util.VN_CURDATE());
|
||||
|
||||
|
@ -20,12 +23,12 @@ BEGIN
|
|||
f.Consumo consumo_anual, c.Vencimiento, ci.grade
|
||||
FROM
|
||||
vn2008.Clientes c
|
||||
JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
|
||||
JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
|
||||
JOIN tmp.risk r ON r.clientFk = c.Id_Cliente
|
||||
JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk
|
||||
JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente
|
||||
GROUP BY Id_cliente;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue