Hi, many thanks for this suggestion. But the problem with this is that you have to know which columns are returned when you call the function. Regards Dirk
Von:
Christoph Moench-Tegeder <cmt@xxxxxxxxxxxxxx> ## Dirk Mika (Dirk.Mika@xxxxxxxxxxxxx):
testing=# CREATE OR REPLACE FUNCTION public.rr(p INTEGER) RETURNS SETOF RECORD LANGUAGE plpgsql AS $function$ BEGIN IF p = 1 THEN RETURN NEXT ('k1'::TEXT, 'v1'::TEXT); RETURN NEXT ('k2'::TEXT, 'v2'::TEXT); ELSE RETURN NEXT (23::INTEGER, 42::INTEGER, 'abc'::TEXT); RETURN NEXT (42::INTEGER, 23::INTEGER, 'xyz'::TEXT); END IF; RETURN; END; $function$; CREATE FUNCTION testing=# SELECT * FROM rr(2) f(a INTEGER, b INTEGER, c TEXT); a | b | c ----+----+----- 23 | 42 | abc 42 | 23 | xyz (2 rows) testing=# SELECT * FROM rr(1) f(x TEXT, y TEXT); x | y ----+---- k1 | v1 k2 | v2 (2 rows) Regards, Christoph -- Spare Space |