on 2012 Nov 09 1:59 PM
Hello all,
Does anyone know what's wrong with the following WHILE statement?
I am trying to write a script on Sybase Anywhere 12.0.1 to alter all integer columns to bigint columns. I wrote the script like below(this is a simplified version). When I ran it, it was always telling me there was a syntax error near 'begin' on line 8. If I took the 'begin ... end' out of the while statement, it would say there was a syntax error near 'fetch' on line 10. What's wrong with while statement? Is it because I have to use loop...end loop for cursor as I saw some examples?
1 BEGIN 2 DECLARE cur CURSOR FOR select table_name from SYSTAB; 3 DECLARE @tablename NCHAR(100); 4 5 open cur with hold; 6 fetch cur into @tablename; 7 WHILE @@fetch_status = 0 8 begin 9 -- do something with cursor 10 fetch cur into @tablename; 11 end 12 CLOSE int_cursor; 13 END
I guess you're mixing Watcom-SQL and T-SQL dialects here.
As most of the code is Watcom-SQL, you should be able to simply adapt the WHILE loop to Watcom-SQL syntax:
WHILE @@fetch_status = 0 LOOP -- do something with cursor fetch cur into @tablename; END LOOP;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.