Problem with Batch interface

33 views
Skip to first unread message

Strakapoud

unread,
Apr 5, 2026, 6:04:08 PM (7 days ago) Apr 5
to firebird...@googlegroups.com
I want to use Batch interface. Because I use Delphi, I converted
"12.batch_isc.cpp" example into Delphi and it works correctly.
But when I replace INSERT command by INSERT+RETURNING or by EXECUTE
BLOCK (without output parameters) it does not work, i.e. no error is
returned, but no rows are inserted into table.

The only difference I can see is in getState:
  i_BatCs := i_Bat.execute(i_status, i_Tran);
  i := i_BatCs.getState(i_status, 0);
which originally returns 1, but after chaging SQL it returns 0.

Any idea what am I missing?

Mark Rotteveel

unread,
Apr 6, 2026, 3:26:50 AM (7 days ago) Apr 6
to firebird...@googlegroups.com
As far as I'm aware, using INSERT ... RETURNING should produce an error
("Invalid type of statement used in batch", 335545185 or isc_batch_type)
when you create the batch. Batch execution cannot be used with INSERT
... RETURNING because of the output row (or result set when using INSERT
... SELECT ... RETURNING on Firebird 5). The same applies for EXECUTE
BLOCK, because even without output parameters, it still effectively has
an output row, that output row just doesn't have any columns.

Batch execution only works for statements that are described as
isc_info_sql_stmt_insert, isc_info_sql_stmt_update,
isc_info_sql_stmt_delete, and maybe isc_info_sql_stmt_select_for_upd.

INSERT .. RETURNING is described as either
isc_info_sql_stmt_exec_procedure or (Firebird 5+ INSERT ... SELECT ...
RETURNING) isc_info_sql_stmt_select. EXECUTE BLOCK without output
parameters (or output parameters + no SUSPEND) is described as
isc_info_sql_stmt_exec_procedure.

Mark
--
Mark Rotteveel

Dimitry Sibiryakov

unread,
Apr 6, 2026, 4:26:54 AM (7 days ago) Apr 6
to firebird...@googlegroups.com
Strakapoud wrote 06.04.2026 0:04:
> Any idea what am I missing?

Do original example work after the same change?
Did you try Firebird 6?

--
WBR, SD.

AlexPeshkoff

unread,
Apr 6, 2026, 1:35:10 PM (7 days ago) Apr 6
to firebird-support
Example works for me with execute block with Firebird 6. 

Pre-6 there is an error:
Message Status
   0   Updated 0 record(s)
   1   Execute failed
Summary: total=2 success=1 success(but no update info)=0
Detailed errors status:
Message 1: request synchronization error

Not good that error is not raised for first record but it's really not added.
This worth fixing - feel free to add an issue to github.

понедельник, 6 апреля 2026 г. в 11:26:54 UTC+3, sd:

Strakapoud

unread,
Apr 6, 2026, 7:56:35 PM (6 days ago) Apr 6
to firebird...@googlegroups.com
Problem was with Firebird 4.

EXECUTE BLOCK does not work (and does not return error) in FB4, but it
works in FB5, FB6.


EXECUTE BLOCK...RETURNS correctly returns error "Invalid type of
statement used in batch" in all FB versions.

INSERT ... RETURNING does not work (as expected), but does not return
error in all FB versions.


Dne 06.04.2026 v 10:26 'Dimitry Sibiryakov' via firebird-support napsal(a):
Reply all
Reply to author
Forward
0 new messages