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!!

asked 24 Sep, 07:26

Sako's gravatar image

Sako
597314064
accept rate: 27%

edited 24 Sep, 07:32


This should work with EXECUTE IMMEDIATE when specifying the variable as a literal value, AFAIK. What exactly have you tried?

permanent link

answered 24 Sep, 08:14

Volker%20Barth's gravatar image

Volker Barth
34.7k337491732
accept rate: 33%

converted 26 Sep, 03:40

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, 08:52) Sako
Replies hidden

You have to include the whole CREATE EVENT statement including the handler block as argument to EXECUTE IMMEDIATE.

(25 Sep, 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, 10:01) Sako

So does it work now?

(25 Sep, 10:37) Volker Barth

Yes, it worked!

(25 Sep, 15:58) Sako
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×36
×6

question asked: 24 Sep, 07:26

question was seen: 130 times

last updated: 25 Sep, 15:58