Disclaimer: This is an "asked-and-answered question" posted in accordance with the FAQ statement that it's "perfectly fine to ask and answer your own programming question". Its purpose is to encourage members of the SQL Anywhere programming community to use StackOverflow by seeding the "sqlanywhere" tag with some real-world content. Edits are welcome, as are other answers, and it has been marked "community wiki" to facilitate that, as well as to avoid claims of gaming the reputation system.
I'm writing a stored procedure for SQL Anywhere 9.0.2, here's some code:
...
declare
@v_d datetime, @v_d1 datetime, @v_d2 datetime
....
select @v_d1 = @v_d, @v_d2 = dateadd(dd, 1, @v_d1)
...
it turns out that @v_d2 will not be set as expected. if I modify it to:
...
declare
@v_d datetime, @v_d1 datetime, @v_d2 datetime
....
select @v_d1 = @v_d
select @v_d2 = dateadd(dd, 1, @v_d1)
...
nothing happens, all the same. finally, I changed it to :
...
declare
@v_d datetime, @v_d1 datetime, @v_d2 datetime
....
begin
select @v_d1 = @v_d
end
begin
select @v_d2 = dateadd(dd, 1, @v_d1)
end
...
now it works fine, looks kind of stupid though. my question is: is it a known issue? or maybe I could do it more neatly? any comments will be appreciated. thanks!