mysql - Issues creating daily event -


trying create daily event in mysql:

create event resetstatus     on schedule       every 1 day            begin              if (date('2013-04-05') = curdate())                 update mytable                 set resetstatus = 1                 id = (select pid usertable priority = 'a');              end if;        end; 

get error:

lookup error - mysql database error: have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 12 

if take update statement , place in toad , run, runs no errors.

as documented under defining stored programs:

if use mysql client program define stored program containing semicolon characters, problem arises. default, mysql recognizes semicolon statement delimiter, must redefine delimiter temporarily cause mysql pass entire stored program definition server.

you need set client use statement delimiter other ;, thinks first semicolon encounters (at end of update statement) terminating create event statement.

in mysql command line client, 1 can use delimiter command:

delimiter ;;  -- or else  create event resetstatus on schedule   every 1 day   begin          if (date('2013-04-05') = curdate())             update mytable             set resetstatus = 1             id = (select pid usertable priority = 'a');          end if;    end ;;  delimiter ;  -- return normal 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -