0

I'm writing Sybase procedure and ran into a problem: how to break inside of a for loop. It just gives me syntax error. Is it possible to skip the current row and go to the next one in for loop?

for TmpUserEvents as TmpUserCursorEvents dynamic scroll cursor for
  select
    *
  from
    test
do

  if flag = 1 then 
    continue; --break;
  end if;

end for;
Dmitrij
  • 13
  • 5
  • possible duplicate of [Syntax of for-loop in SQL Server](http://stackoverflow.com/questions/6069024/syntax-of-for-loop-in-sql-server) – Mike Gardner Apr 25 '14 at 13:25
  • T-SQL does not have a for loop. You will need to use `while`, `break` and `continue` http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc32300.1550/html/sqlug/X51638.htm – Mike Gardner Apr 25 '14 at 13:26

1 Answers1

0

To answer my own question: it is possible to continue for loop while executing.

for TmpUserEvents as TmpUserCursorEvents dynamic scroll cursor for
  select
    *
  from
    test
do
   lbl:
   loop
    if condition = 1 then
      leave lbl;
    end if;
   end loop lbl;
end for;
Dmitrij
  • 13
  • 5