Let's say I have a code like this:
execute block
as
declare var_mask bigint;
declare var_dummy int;
begin
var_mask = bin_shl(1, (64 - 1));
execute statement ('
select first 1 null
from rdb$database
where bin_and(cast(0 as bigint), :var_mask) <> cast(0 as bigint)
')
(var_mask := var_mask)
into :var_dummy
;
end
This one gives nice arithmetic exception, numeric overflow, or string truncation.
numeric value is out of range.
.
To make it work I have to do explicit cast of the variable:
execute block
as
declare var_mask bigint;
declare var_dummy int;
begin
var_mask = bin_shl(1, (64 - 1));
execute statement ('
select first 1 null
from rdb$database
where bin_and(cast(0 as bigint), cast(:var_mask as bigint)) <> cast(0 as bigint)
')
(var_mask := var_mask)
into :var_dummy
;
end
Does anybody know why? The type information should carry, isn't it?
To add to Adriano's answer the type information actually does not carry - more here, from me actually :).