I use PostgreSQL ver 8.4 and wrote the following custom grouping function:
CREATE OR REPLACE FUNCTION custom_group(integer)
RETURNS TABLE (
grp INTEGER,
entry_date DATE,
col1 REAL,
col2 REAL,
col3 REAL,
col4 REAL,
col5 INTEGER,
col6 INTEGER) AS
$BODY$
SELECT ceil(rank() OVER (ORDER BY entry_date) / $1)::int as grp
,entry_date, col1, col2, col3, col4, col5, col6
FROM table_foo
ORDER BY 1;
$BODY$ LANGUAGE SQL;
When I try to import a function in psql, I get the following error:
Final statement returns bigint instead of integer
I do not understand the error message, especially since I am expecting a return of type RECORD (well table).
What causes the error and how to fix it?
[[Edit]]
I changed the grp data type to BIGINT, as suggested in the comments, however I got the same error. Details:
ERROR: return type mismatch in function declared to return record
DETAIL: Final statement returns integer instead of bigint at column 1.
CONTEXT: SQL function "custom_group"
source
share