MySQL语法错误事件调度程序

时间:2016-10-06 03:23:35

标签: mysql

出了什么问题? 我成功创建了预定的活动。 它没有工作,并且在“结束”附近出现了问题。语法,MySQL说......

 DELIMITER ||
CREATE
EVENT ScheduledCalls
ON SCHEDULE EVERY 5 MINUTE
STARTS NOW()
ON COMPLETION PRESERVE
DO
BEGIN
    -- insert if less than 60 minutes
    INSERT INTO tblcalls(
        DateTimeReceived, ClientID, CorpName, StartDay,
        StartTime, FromInfo, FromContact, FromPhone, ToInfo,
        ToContact, ToPhone, Memo,Service, StrService, AR, Status)
    SELECT
        DateTimeReceived, ClientID, CorpName, StartDay,
        StartTime, FromInfo, FromContact, FromPhone, ToInfo,
        ToContact, ToPhone, Memo, Service, StrService, AR, Status
    FROM 
        tblscheduledcalls
    WHERE
        TIMEDIFF(StartDateTime, NOW()) < "00:60:00";

    -- delete inserted record(s) from tblcalls
    DELETE FROM tblscheduledcalls
    WHERE
        TIMEDIFF(StartDateTime, NOW()) < "00:60:00";
END ||
DELIMITER ;

1 个答案:

答案 0 :(得分:0)

试试这个:

DELIMITER $$
CREATE
EVENT ScheduledCalls
ON SCHEDULE EVERY 5 MINUTE
STARTS NOW()
ON COMPLETION PRESERVE
DO
BEGIN
    -- insert if less than 60 minutes
    INSERT INTO tblscheduledcalls(
        DateTimeReceived, ClientID, CorpName, StartDay,
        StartTime, FromInfo, FromContact, FromPhone, ToInfo,
        ToContact, ToPhone, Memo,Service, StrService, AR, Status)
    SELECT
        DateTimeReceived, ClientID, CorpName, StartDay,
        StartTime, FromInfo, FromContact, FromPhone, ToInfo,
        ToContact, ToPhone, Memo, Service, StrService, AR, Status
    FROM 
        tblcalls
    WHERE
        TIMEDIFF(StartDateTime, NOW()) < "00:60:00";

    -- delete inserted record(s) from tblcalls
    DELETE FROM tblscheduledcalls
    WHERE
        TIMEDIFF(StartDateTime, NOW()) < "00:60:00";
END;
$$
DELIMITER ;