0

I am trying to create this event but I cannot find the syntax error.

DELIMITER //
CREATE EVENT IF NOT EXISTS auto_decline
ON SCHEDULE
    EVERY 1 DAY
DO
    UPDATE Appointment SET status = 'Declined' WHERE deadline < CURDATE();
END; //
DELIMITER ;

so Basically I want my database to check every day that if the deadline (deadline is a column with date format) is already bigger than the current date. However my systems tells me there is a syntax error. I also tried to use a IF THEN statement

DELIMITER //
CREATE EVENT IF NOT EXISTS auto_decline
ON SCHEDULE
    EVERY 1 DAY
DO
    IF deadlineToAccept BETWEEN offerSentTime AND CURDATE()
    THEN
    UPDATE PatientReceivedAppointment SET status = 'Declined';
END IF;
END; //
DELIMITER ;

enter image description here

still I got this syntax error. Notice that in my code there is no warning.enter image description here

Shadow
  • 33,525
  • 10
  • 51
  • 64

1 Answers1

1

A function, event, trigger, or procedure usually has a body like BEGIN ... END. When there is only one statement in the body, the BEGIN and END can be omitted. Here, you have left out the BEGIN but left in the END; either remove the END or add a BEGIN.

ysth
  • 96,171
  • 6
  • 121
  • 214