Compare commits
5 Commits
d75a032d75
...
69a34ab0fa
Author | SHA1 | Date |
---|---|---|
Pablo Natek | 69a34ab0fa | |
Pablo Natek | 1731af13ea | |
Pablo Natek | e479873547 | |
Pablo Natek | 92f699aac3 | |
Pablo Natek | e38c061deb |
|
@ -6,25 +6,27 @@ BLOCK1: BEGIN
|
|||
DECLARE vShipped DATE;
|
||||
DECLARE vPreviousShipped DATE;
|
||||
DECLARE vDone boolean;
|
||||
DECLARE cur cursor for
|
||||
|
||||
SELECT clientFk, firstShipped
|
||||
FROM bs.clientNewBorn;
|
||||
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT clientFk, firstShipped
|
||||
FROM bs.clientNewBorn;
|
||||
|
||||
DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
SET vDone := FALSE;
|
||||
|
||||
DELETE FROM bs.clientNewBorn WHERE isModified = FALSE;
|
||||
|
||||
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
|
||||
SELECT c.id, MAX(t.shipped), MAX(t.shipped)
|
||||
FROM vn.client c
|
||||
JOIN vn.ticket t on t.clientFk = c.id
|
||||
LEFT JOIN clientNewBorn cb on cb.clientFk = c.id
|
||||
WHERE t.shipped BETWEEN TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) AND util.VN_CURDATE() AND cb.isModified is null
|
||||
GROUP BY c.id;
|
||||
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
|
||||
SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped))
|
||||
FROM vn.client c
|
||||
JOIN vn.ticket t ON t.clientFk = c.id
|
||||
LEFT JOIN clientNewBorn cb ON cb.clientFk = c.id
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||
AND util.VN_CURDATE()
|
||||
AND cb.isModified IS NULL
|
||||
GROUP BY c.id;
|
||||
|
||||
OPEN cur;
|
||||
|
||||
LOOP1: LOOP
|
||||
SET vDone := FALSE;
|
||||
FETCH cur INTO vClientFk, vShipped;
|
||||
|
|
Loading…
Reference in New Issue