I'm new to sql so bear with me, but I'm trying to create an event that will populate the row of a table at a specific time with values from 1 to x where x is a pre-declared variable. I'm attempting to use a delimiter for the first time and I'm not really sure where all my semi-colons should be at but the following is what I assumed after a while of reading:
DELIMITER $$
DECLARE day_m INT DEFAULT 0;
SET day_m = DATE_FORMAT(CURRENT_DATE, '%e');
WHILE day_m <= DATE_FORMAT(LAST_DAY(CURRENT_DATE), '%e')
BEGIN
INSERT INTO monthly_scheduling (days) values (day_m)
SET day_m = day_m + 1
END;
$$
DELIMITER ;
The error I'm getting is as follows: MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '$$ DECLARE day_m INT DEFAULT 0; SET day_m = DATE_FORMAT(CURRENT_DATE, ' at line 1
I've been trying all sorts of things but I can't get the event to create because of the error I seem to keep getting at the DECLARE
section. Any help would be much appreciated.