I know that Postgres allows to return a predefined composite datatype, a record and a table with column definition.
However I did not manage to return a simple record with defined columns so I always use tables even if I know that this will only return one line.
So my function definition looks something like this:
CREATE OR REPLACE FUNCTION name(p_param1 text, p_param2 json)
RETURNS TABLE(
col1 bigint,
col2 integer,
col3 integer
)
If I try do return a record the same way it fails:
CREATE OR REPLACE FUNCTION name(p_param1 text, p_param2 json)
RETURNS RECORD(
col1 bigint,
col2 integer,
col3 integer
)
Is this not possible in Postgres? I know that I can just declare a custom composite data type but I don't want to declare a type for every function returning a record.