Subject Firebird : Arithmetic overflow exception only in execute block statement
Author Issam Boughanmi
i have this heterogeneous cross database query

execute block as 
DECLARE panum INT; 
DECLARE nom varchar(50); 
DECLARE prenom varchar(50); 
DECLARE dna date; 
DECLARE datemodif date; 
DECLARE m date; 
DECLARE VARIABLE VSQL VARCHAR(100); 
begin 
  VSQL = 'select panum, nom, prenom, dna, DATEMODIF from patient where 
  (datemodif is not null ) and (datediff (day from current_date to 
  cast(DATEMODIF as date))>-2)';

  FOR execute statement VSQL ON EXTERNAL DATA SOURCE 
  'localhost/3050:C:/BDD/Replications/Source/D2018.gdb' AS USER 'sysdba' 
  PASSWORD 'masterkey'
  INTO :panum, :nom, :prenom, :dna, :DATEMODIF DO  

 suspend;
end; 

wich give me an arithmetic overflow or string truncation error .

if i run the query in a single database it work fine

select panum, nom, prenom, dna, DATEMODIF from patient where (datemodif is 
not null ) and (datediff (day from current_date to cast(DATEMODIF as 
date))>-2)


if i remove the datediff where clause condition in the original query it work also.

the two databases are exactly the same (schema and data), actually it's a copy/paste .

any idea on what's going on please ?