Answer the question
In order to leave comments, you need to log in
Why does "Final statement returns bigint instead of integer" error occur in SQL function?
Good afternoon! Tell me, please, what could cause an error when trying to create a table function in the POSTGRESQL database?:
ERROR: return type mismatch in function declared to return record
DETAIL: Final statement returns bigint instead of integer at column 2.
create or replace function "bd"."function"("reg" int4, "date" date)
returns table("4.1" int4, "5.1" bigint, ) as $body$
ERROR: return type mismatch in function declared to return record
DETAIL: Final statement returns too many columns.
Answer the question
In order to leave comments, you need to log in
The data types as they are declared in the output parameters of the function do not match what you are trying to do in return. Should match each other.
sum in pg13 we have these:
melkij=> \da pg_catalog.sum
Список агрегатных функций
Схема | Имя | Тип данных результата | Типы данных аргументов | Описание
------------+-----+-----------------------+------------------------+--------------------------------------------------
pg_catalog | sum | numeric | bigint | sum as numeric across all bigint input values
pg_catalog | sum | double precision | double precision | sum as float8 across all float8 input values
pg_catalog | sum | bigint | integer | sum as bigint across all integer input values
pg_catalog | sum | interval | interval | sum as interval across all interval input values
pg_catalog | sum | money | money | sum as money across all money input values
pg_catalog | sum | numeric | numeric | sum as numeric across all numeric input values
pg_catalog | sum | real | real | sum as float4 across all float4 input values
pg_catalog | sum | bigint | smallint | sum as bigint across all smallint input values
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question