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
I wrote:

> 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.

At least, that's what the documentation (Borland's and ours) says. But given
an exception EX_CONTINUE, and a table T with int column C and three records,
the following block:

execute block returns (s varchar(40))
as
declare i int;
begin

for select c from t into i do
begin
if (s is null) then s = 'a'; else s = s || 'a';

if (s = 'aa') then
begin
s = 'bb';
exception ex_continue;
end

suspend;

when exception ex_continue do begin end
end

end#

returns

a
bba

I.e., the actions performed in the inner block (where the exception isn't
handled) are *not* reversed. Maybe only SQL actions are rolled back? That
would make sense: internally, savepoints are used for this. But it's yet
another thing to be aware of.


Cheers,
Paul Vinkenoog