1
我有以下SQL腳本執行自定義分隔符查詢,我想用multiquery如何使用mysqli的multiquery
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 ;
並將$$
替換爲;
並使用多查詢執行,它會起作用嗎?