You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
recreate table test (
id int,
val int
);
commit;
insert into test(id, val) values (1, 10);
commit;
set term ^;
execute block as
declare curVal integer;
declare curID integer;
begin
for select id, val
from test
where id = 1
into curid, curval
as cursor cur1
do begin
update test
set val=123
where current of cur1;
rdb$set_context('USER_SESSION','EXE_BLOCK_UPDATE_1_ROW_COUNT', row_count );
update test
set val=456
where current of cur1;
rdb$set\_context\('USER\_SESSION','EXE\_BLOCK\_UPDATE\_2\_ROW\_COUNT', row\_count \);
update test
set val=789
where current of cur1;
rdb$set\_context\('USER\_SESSION','EXE\_BLOCK\_UPDATE\_3\_ROW\_COUNT', row\_count \);
end
end
^
set term ;^
set list on;
select mon$variable_name as ctx_var, mon$variable_value as ctx_value from mon$context_variables;
quit;
Its output will be:
CTX_VAR EXE_BLOCK_UPDATE_1_ROW_COUNT
CTX_VALUE 1
CTX_VAR EXE_BLOCK_UPDATE_2_ROW_COUNT
CTX_VALUE 2
CTX_VAR EXE_BLOCK_UPDATE_3_ROW_COUNT
CTX_VALUE 3
Value of ROW_COUNT was incremented by 1 all subsequent UPDATE statements that was executed within cursor ("where current of cursor cur1").
The text was updated successfully, but these errors were encountered:
Submitted by: @pavel-zotov
Run following script:
recreate table test (
id int,
val int
);
commit;
insert into test(id, val) values (1, 10);
commit;
set term ^;
execute block as
declare curVal integer;
declare curID integer;
begin
for select id, val
from test
where id = 1
into curid, curval
as cursor cur1
do begin
update test
set val=123
where current of cur1;
rdb$set_context('USER_SESSION','EXE_BLOCK_UPDATE_1_ROW_COUNT', row_count );
end
^
set term ;^
set list on;
select mon$variable_name as ctx_var, mon$variable_value as ctx_value from mon$context_variables;
quit;
Its output will be:
CTX_VAR EXE_BLOCK_UPDATE_1_ROW_COUNT
CTX_VALUE 1
CTX_VAR EXE_BLOCK_UPDATE_2_ROW_COUNT
CTX_VALUE 2
CTX_VAR EXE_BLOCK_UPDATE_3_ROW_COUNT
CTX_VALUE 3
Value of ROW_COUNT was incremented by 1 all subsequent UPDATE statements that was executed within cursor ("where current of cursor cur1").
The text was updated successfully, but these errors were encountered: