cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

loop error,pls

ximen
Participant
0 Likes
4,064
declare @product_code char(10),@rowNR int,@Mrow int
set     i=1
select product_code,row_number() over(order by parent_id) as rowNR,parent_id into #FT_1 from product_code where parent_id='cp'
//select * from #ft_1
//select @mrow=max(rowNR) from #ft_1 
//select @mrow      
while  i<=29 LOOP
    select @product_code=product_code from #ft_1 where i=rownr
select @product_code
set i=i+1
end loop

select * from #t1

error loop alt text

View Entire Topic
MarkCulp
Participant

I think the problem that you are having is that you are mixing WATCOM SQL with TSQL. The WHILE ... LOOP statement is WATCOM SQL whereas the TSQL variant of a WHILE statement does not use the LOOP keyword. You have been using TSQL procedures so you need to use a WHILE statement - i.e. remove the LOOP and END LOOP and add in a BEGIN ... END.

OR alternatively, switch to using WATCOM SQL.

HTH

ximen
Participant
0 Likes

WATCOM SQL so I should go to where to find relevant learning materials

MarkCulp
Participant
0 Likes

My answer contains the two relevant links for the two variants of the WHILE statement. You can find all of the documentation for SQL Anywhere at http://dcx.sybase.com/index.html