Hello, is there any way to use a variable (of type time) in the statement of creating an event? begin set @time = '09:00'; create event myevent schedule start time @time every 5 minutes handler begin end; end I tried even with execute immediate without success!! |
This should work with EXECUTE IMMEDIATE when specifying the variable as a literal value, AFAIK. What exactly have you tried? I am trying to execute this block: begin declare @time1 time; set @time1 = '09:00'; execute immediate ('create event SyncPrAtH schedule start time ''' + convert(varchar(5), @time1) + ''' every 3 minutes handler'); begin select * from dummy; end; end;
(25 Sep '19, 08:52)
Baron
Replies hidden
You have to include the whole CREATE EVENT statement including the handler block as argument to EXECUTE IMMEDIATE.
(25 Sep '19, 09:16)
Volker Barth
Oh, Sorry!! I dont know why I was so fast to post it here before looking more closely into my code. Thank you
(25 Sep '19, 10:01)
Baron
So does it work now?
(25 Sep '19, 10:37)
Volker Barth
Yes, it worked!
(25 Sep '19, 15:58)
Baron
|