Why is is that when using SET to set variables, in some cases multiple variables can be set with one statement and in others two separate ones need to be issued.
For example this works fine:
SET
@uname := 'John',
@acct_trade := 218.01,
@acct_labor := 518.01,
@acct_cntgy := 818.01;
Only one semicolon is used.
However when its something like this:
SET @datestart := '2012-01-01',
SET @dateend := '2012-02-29';
It doesn’t work. I have to make them each its own call.
SET @datestart := '2012-01-01';
SET @dateend := '2012-02-29';
I am assuming that this has something to do with the fact that its asking for 2 strings. I even tried casting it to date.
Any ideas?
In the example that fails, you have the
SETkeyword twice. If you remove it from the second line it should work:This is because the
SETkeyword acts as a full statement up-until the ending semi-colon. When it hits anotherSETkeyword, it’s invalid syntax.