Subject Re: Execute statement and sum
Author Adam
--- In firebird-support@yahoogroups.com, "Milan Babuskov" <milanb@...>
wrote:
>
> 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?


insert into t1 (x) values (2147483647);
insert into t1 (x) values (12345);

Now try again ;)

Adam