我有以下SQL脚本,我想多查询来执行它
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 ;
有没有办法做到这一点? 它会工作,如果我只是删除DELIMITER $$
和DELIMITER ;
从脚本和替换$$
通过;
并与多查询执行?