Is it possible to express return type of stored procedure that returns joined tables using table type of one of joined tables?
My stored procedure looks like this:
CREATE or REPLACE FUNCTION selectJoin()
RETURNS SETOF ???
AS $$
BEGIN
RETURN QUERY SELECT t1.*, t2.name
FROM t1, t2
WHERE t1.t2_id = t2.id;
END; $$
LANGUAGE plpgsql;
Table t1
has many (approx 70) columns so I’d like to somehow reuse the t1
type in RETURNS clause. Something like (t1, varchar(30))
or composite type inheritace. Is is possible?
PostgreSQL version 9.3