DECLARED TEMP TABLE. Error "SQLSTATE = 22000 / no current record for fetch" may unexpectedly raise.

46 views
Skip to first unread message

Pavel Zotov

unread,
Sep 1, 2026, 6:22:20 AMSep 1
to firebird-devel
'
Please consider following script:
========
set bail on;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;
create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
set list on;
set autoterm on;
recreate table ltt_test(txt varchar(10));
--recreate local temporary table ltt_test(txt varchar(10)) on commit preserve rows;
--recreate global temporary table ltt_test(txt varchar(10)) on commit preserve rows;

execute block returns(cnt int) as
    declare temporary table ltt_test(txt varchar(10)); ------------ [ 1 ]
begin
    insert into ltt_test(txt) values('foo');
    for
        select txt
        from ltt_test
        as cursor c
    do begin
        select 1 from ltt_test u
        where u.txt= c.txt
        order by 1 ------------------------------------------------ [ 2 ]
        rows 1
        into cnt;
        suspend;
    end
end;

========

It will issue error:
========
Statement failed, SQLSTATE = 22000
no current record for fetch operation
-At block line: 13, col: 9
========

Now let's comment out statements marked as either [ 1 ] or [ 2 ] and repeat.
Script will complete OK and issue:
CNT              1

(and same if we try with global or local temporary tables; only DECLARED temp table is affected).

Checked on 20260829_024127-6.0.0.2164-2d371e2.

Pavel Zotov

unread,
Sep 1, 2026, 6:25:50 AMSep 1
to firebird-devel
PS.
Of course, code inside the for-select cursor looks like nonsense; the original example is completely different and more complex.

Adriano dos Santos Fernandes

unread,
Sep 2, 2026, 7:48:56 AMSep 2
to firebir...@googlegroups.com
Should be fixed now.


Adriano

Pavel Zotov

unread,
Sep 2, 2026, 12:28:23 PMSep 2
to firebird-devel

Should be fixed now.

Confirmed fix on 6.0.0.2166-f81c786.  Test has been committed.
 
Reply all
Reply to author
Forward
0 new messages