fix: add date format on insert data #3135
|
@ -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;
|
||||
OPEN cur;
|
||||
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