Subject | Execute statement and sum |
---|---|
Author | Milan Babuskov |
Post date | 2007-06-19T20:21:20Z |
Hi,
I ran into a strange problem and I'm trying to understand why it works
like this. What should be the data type of SUM() function over an
integer column?
I thought that SUM(integer) yields integer, but it looks like it is
not the case as "execute statement" fails with error about
incompatible types. Consider this simple example:
create table t1
(
x integer
);
commit;
set term !! ;
execute block
as
DECLARE VARIABLE sumx integer;
begin
execute statement 'select sum(x) from t1'
into :sumx;
end!!
I get this error:
Variable type (position 0) in EXECUTE STATEMENT 'select sum(x) from
t1' INTO does not match returned column type.
I know I can work around it by casting the SUM to integer, but I'd
like to know why it works this way. Perhaps this is a question for
devel list?
Thanks,
M.
I ran into a strange problem and I'm trying to understand why it works
like this. What should be the data type of SUM() function over an
integer column?
I thought that SUM(integer) yields integer, but it looks like it is
not the case as "execute statement" fails with error about
incompatible types. Consider this simple example:
create table t1
(
x integer
);
commit;
set term !! ;
execute block
as
DECLARE VARIABLE sumx integer;
begin
execute statement 'select sum(x) from t1'
into :sumx;
end!!
I get this error:
Variable type (position 0) in EXECUTE STATEMENT 'select sum(x) from
t1' INTO does not match returned column type.
I know I can work around it by casting the SUM to integer, but I'd
like to know why it works this way. Perhaps this is a question for
devel list?
Thanks,
M.