I once had a "mysterious missing records" problem. Turned out to be a wrong delete statement in our application.
I learned that FirebirdSQL can execute statements in an external database. Below script served me well for importing missing records at that time.
set term ^ ;
execute block
as
declare aorderdetailid integer;
declare aorderid integer;
declare aorderdayid integer;
declare aproductid varchar(100);
declare aproductname varchar(200);
declare aprice double precision;
declare aqty double precision;
declare aqtyupdate double precision;
declare aunit varchar(20);
declare afree smallint;
declare avat double precision;
declare apaidqty integer;
declare aentryuser varchar(100);
declare aprinted smallint;
declare aadditionprintedqty double precision;
declare akitchensend smallint;
declare aproductnotes varchar(150);
declare acost double precision;
declare awaiting smallint;
begin
for execute statement 'select orderdetailid, orderid, orderdayid, productid, productname, price, qty, qtyupdate, unit, free, vat, paidqty, entryuser, printed, additionprintedqty, kitchensend, productnotes, cost, waiting from orderdetail where orderid in (select orderid from orders where rdate >= ''2021-07-01'' and rdate <= ''2021-07-04'')'
on external data source 'localhost:E:\DBs\arsiv\ARSIV.FDB' as user 'your_db_user' password 'your_db_password'
into :aorderdetailid, :aorderid, :aorderdayid, :aproductid, :aproductname, :aprice, :aqty, :aqtyupdate, :aunit, :afree, :avat, :apaidqty, :aentryuser, :aprinted, :aadditionprintedqty, :akitchensend, :aproductnotes, :acost, :awaiting do
begin
insert into orderdetail(orderdetailid, orderid, orderdayid, productid, productname, price, qty, qtyupdate, unit, free, vat, paidqty, entryuser, printed, additionprintedqty, kitchensend, productnotes, cost, waiting)
values(:aorderdetailid, :aorderid, :aorderdayid, :aproductid, :aproductname, :aprice, :aqty, :aqtyupdate, :aunit, :afree, :avat, :apaidqty, :aentryuser, :aprinted, :aadditionprintedqty, :akitchensend, :aproductnotes, :acost, :awaiting);
end
end^
set term ; ^
It seems complicated at first, but it is very simple in its core.
0- Adjust the above script to your needs.
1- Use the command line ISQL tool to connect to the database where you have missing records.
2- Run your own script to insert only missing records.
3- Do not forget to COMMIT.
I hope that helps.