我在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

关于mysql - 创建mysql过程时出现错误1064,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57019115/

10-09 20:13
查看更多