簡體   English   中英

創建mysql過程時出現錯誤1064

[英]error 1064 while creating mysql procedure

我在HeidiSql中創建mySql過程:

   CREATE DEFINER=root@localhost PROCEDURE checkSchedule
 ( IN sDate date, IN eDate date, IN sTime time, IN eTime time, IN weekDay int(7), IN classId int(11) )
   BEGIN 
   select schedule.idSchedule 
       from schedule 
          where ( (sDate>=schedule.startDate and sDate<=schedule.endDate) 
       or (sDate<=schedule.startDate and eDate>=schedule.endDate) 
       or (eDate>=schedule.startDate and eDate<=schedule.endDate) ) 
       and ( (sTime>=schedule.startTime and sTime<=schedule.endTime) 
       or (sTime<=schedule.startTime and eTime>=schedule.endTime) 
       or (eTime>=schedule.startTime and eTime<=schedule.endTime) ) 
       and weekDay=schedule.weekDay and classId=schedule.classroom_idClassRoom; 
    END

我收到下一個錯誤:

    SQL Error (1064): check the manual corresponds your MariaDB server 
    version for the right syntax to use near '' at line 12

任何想法如何解決這個問題?

您需要臨時更改DELIMITER以執行該過程。 默認DELIMITER為; 但是在創建您使用的程序時; 因此會產生問題。

DELIMITER $$
CREATE DEFINER=root@localhost PROCEDURE checkSchedule
 ( IN sDate date, IN eDate date, IN sTime time, IN eTime time, IN weekDay int(7), IN classId int(11) )
   BEGIN 
   select schedule.idSchedule 
       from schedule 
          where ( (sDate>=schedule.startDate and sDate<=schedule.endDate) 
       or (sDate<=schedule.startDate and eDate>=schedule.endDate) 
       or (eDate>=schedule.startDate and eDate<=schedule.endDate) ) 
       and ( (sTime>=schedule.startTime and sTime<=schedule.endTime) 
       or (sTime<=schedule.startTime and eTime>=schedule.endTime) 
       or (eTime>=schedule.startTime and eTime<=schedule.endTime) ) 
       and weekDay=schedule.weekDay and classId=schedule.classroom_idClassRoom; 
    END$$

 DELIMITER ;

DEMO

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM