Start a new topic

Use Variables in fetch into

[This topic is migrated from our old forums. The original author name has been removed]

Hi! I have done this in SQL managment studio and now we use DbVisualizer. How do I make the variables to work in DbVisualizer? BEGIN TRANSACTION T1; DECLARE @v1 varchar(255); DECLARE get_main CURSOR FOR SELECT id1 FROM tabel1; OPEN get_main; FETCH NEXT FROM get_main INTO @v1; WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO table2 (id1, f1) VALUES (@v1, '11'); FETCH NEXT FROM get_main INTO @v1; END CLOSE get_main; DEALLOCATE get_main; Grateful for help!

[This reply is migrated from our old forums.]

Re: Use Variables in fetch into
Hej LillaMy, What kind of problem occur when you run the script? Please also note that to run this block of SQL in the SQL Commander check the following: http://confluence.dbvis.com/display/UG91/Executing+Complex+Statements Regards Roger
[This reply is migrated from our old forums. The original author name has been removed]

Re: Use Variables in fetch into
15:16:31 [FETCH - 0 row(s), 0.000 secs] [Error Code: 137, SQL State: S0002] Must declare the scalar variable "@v1".
[This reply is migrated from our old forums.]

Re: Use Variables in fetch into
Thanks. Please check the page I referenced to in my previous post: http://confluence.dbvis.com/display/UG91/Executing+Complex+Statements Regards Roger
[This reply is migrated from our old forums. The original author name has been removed]

Re: Use Variables in fetch into
Thank you! It solved my problem. :)