fix: add date format on insert data #3135
|
@ -7,24 +7,23 @@ BLOCK1: BEGIN
|
||||||
DECLARE vPreviousShipped DATE;
|
DECLARE vPreviousShipped DATE;
|
||||||
DECLARE vDone boolean;
|
DECLARE vDone boolean;
|
||||||
DECLARE cur cursor for
|
DECLARE cur cursor for
|
||||||
|
|
||||||
SELECT clientFk, firstShipped
|
|
||||||
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