Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROW_COUNT is incremented by 1 all subsequent UPDATE statements that are executed within cursor and actually can affect only 1 record [CORE5803] #6065

Open
firebird-automations opened this issue Apr 22, 2018 · 0 comments

Comments

@firebird-automations
Copy link
Collaborator

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant