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 vShipped DATE;
|
||||||
DECLARE vPreviousShipped DATE;
|
DECLARE vPreviousShipped DATE;
|
||||||
DECLARE vDone boolean;
|
DECLARE vDone boolean;
|
||||||
DECLARE cur cursor for
|
|
||||||
|
DECLARE cur CURSOR FOR
|
||||||
SELECT clientFk, firstShipped
|
SELECT clientFk, firstShipped
|
||||||
FROM bs.clientNewBorn;
|
FROM bs.clientNewBorn;
|
||||||
|
|
||||||
DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE continue HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
SET vDone := FALSE;
|
SET vDone := FALSE;
|
||||||
|
|
||||||
DELETE FROM bs.clientNewBorn WHERE isModified = FALSE;
|
DELETE FROM bs.clientNewBorn WHERE isModified = FALSE;
|
||||||
|
|
||||||
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
|
INSERT INTO clientNewBorn(clientFk, firstShipped, lastShipped)
|
||||||
SELECT c.id, MAX(t.shipped), MAX(t.shipped)
|
SELECT c.id, DATE(MAX(t.shipped)), DATE(MAX(t.shipped))
|
||||||
FROM vn.client c
|
FROM vn.client c
|
||||||
JOIN vn.ticket t on t.clientFk = c.id
|
JOIN vn.ticket t ON t.clientFk = c.id
|
||||||
LEFT JOIN clientNewBorn cb on cb.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
|
WHERE t.shipped BETWEEN util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||||
GROUP BY c.id;
|
AND util.VN_CURDATE()
|
||||||
|
AND cb.isModified IS NULL
|
||||||
|
GROUP BY c.id;
|
||||||
|
|
||||||
OPEN cur;
|
OPEN cur;
|
||||||
|
|
||||||
LOOP1: LOOP
|
LOOP1: LOOP
|
||||||
SET vDone := FALSE;
|
SET vDone := FALSE;
|
||||||
FETCH cur INTO vClientFk, vShipped;
|
FETCH cur INTO vClientFk, vShipped;
|
||||||
|
|
Loading…
Reference in New Issue