MySql - How to make a Stored procedure be activated once a day?

0

I need a Stored Procedure to be called every day at 23:59:00 but I have already tried it in some ways and when it arrives at that time it does not execute!

    CREATE EVENT 'ATUALIZARDADOS' ON SCHEDULE
    EVERY 1 DAY STARTS '2017-11-16 23:59:00' ON COMPLETION PRESERVE
    DO 
    begin
    CALL MULTAOFF();
    CALL RESERVAOFF();
    INSERT INTO configuracao (id,DiasMulta,DiasLivroMaior,DiasLivroMenor) 
    values ('8','2','3','4');
    end &&
    delimiter ;

detail, this snippet was just so I can know if the event is working or not)

    INSERT INTO configuracao (id,DiasMulta,DiasLivroMaior,DiasLivroMenor) 
    values ('8','2','3','4');

Can anyone help me with this problem?

    
asked by anonymous 17.11.2017 / 13:50

1 answer

0

You will need to create a job that will run this process.

Job

JOB is a way to assist in maintenance with tasks that must be performed several times the same or on a certain date in particular without requiring DBA intervention, for example defragmenting a table on Sunday. Since on Sunday nobody will be in the company can be scheduled the work to be executed in that period.

JOBs can be created in two ways either through Enterprise Manager or T-SQL, in this article I'll show you two ways we can use to create a JOB.

Example

The creation will be something along these lines:

CREATE 
    EVENT 'archive_blogs' 
    ON SCHEDULE EVERY 1 WEEK STARTS '2011-07-24 03:00:00' 
    DO BEGIN

        -- copy deleted posts
        INSERT INTO blog_archive (id, title, content) 
        SELECT id, title, content
        FROM blog
        WHERE deleted = 1;

        -- copy associated audit records
        INSERT INTO audit_archive (id, blog_id, changetype, changetime) 
        SELECT audit.id, audit.blog_id, audit.changetype, audit.changetime 
        FROM audit
        JOIN blog ON audit.blog_id = blog.id
        WHERE blog.deleted = 1;

        -- remove deleted blogs and audit entries
        DELETE FROM blog WHERE deleted = 1;

    END */$$

DELIMITER ;

You can put in the body absolutely any valid code execution.

Read more

    
17.11.2017 / 14:15