Search code examples
t-sqlfor-loopsybaseprocedurecontinue

Sybase. Break or continue inside of a for loop


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;

Solution

  • 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;