To add to Adriano's answer the type information actually does not carry - more here, from me actually :).
Firebird's execute statement with bigint named input parameter
-
01-09-2022 - |
Domanda
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?
Soluzione 2
Altri suggerimenti
Because BIN_AND describes the second parameter as INTEGER, even when you pass a BIGINT to the first one. Whether this is good or bad is subject to discussion.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow