Subject Re: [firebird-support] FOR SELECT Commands to skip to the next record without any further processing of code contained between the BEGIN END markers
Author Paul Vinkenoog
Hello Mike,

> I'm aware of the LEAVE command that will allow me to exit a FOR SELECT loop
> inside of my store procedure.
>
> Is there a command that will allow me to skip any further processing of code
> contained within the BEGIN END markers and simply process the next record?

Not that I know of. But you can use a (rather ugly) hack: define an exception
and raise it at the point where you would actually like to use CONTINUE or
NEXT or whatever. Catch the exception just before the final END of the loop
so it won't propagate and terminate the procedure or trigger. Now the loop
will enter its next round.

You have to be careful though: if there are any inner BEGIN...END blocks in
the loop and the exception is raised from there, all the actions performed
in that block will be undone. This may or may not be what you want. So test
you code thoroughly if you don't want any unpleasant surprises later.

Also, be aware that it's a long time ago that I last used this trick, so
I may not have all the details right.

BTW, a NEXT/SKIP/CONTINUE statement would be a nice feature request for the
Tracker (if it isn't already in there).


Paul Vinkenoog