I have the following sql script and I want to execute it with multi-query
DELIMITER $$
DROP FUNCTION IF EXISTS `getAttendanceHistoryDates`$$
CREATE FUNCTION getAttendanceHistoryDates(processDate date)
RETURNS TEXT
DETERMINISTIC
LANGUAGE SQL
BEGIN
DECLARE minDate date;
DECLARE startYear int;
DECLARE endYear int;
DECLARE dateString TEXT;
SET minDate = (SELECT MIN(date) FROM `ohrm_attendance_report`);
SET startYear = YEAR(minDate);
SET endYear = YEAR(processDate);
SET dateString = processDate;
WHILE startYear < endYear DO
SET dateString = CONCAT(dateString,'|',CONCAT(startYear, '-12-31'));
SET startYear = startYear + 1;
END WHILE;
RETURN dateString;
END;
$$
DELIMITER ;
Is there a way to do this? Will it work if I just remove DELIMITER $$
and DELIMITER ;
from the script and replace $$
by ;
and execute with multi-query?