I know that a table can be return from a postgresql function as below,
CREATE OR REPLACE FUNCTION public.tmp()
RETURNS table(num int, name text)
LANGUAGE plpgsql
AS $function$
DECLARE rslt record;
begin
for rslt in select * from t1 loop num:=rslt.num; name:=rslt.name; return next; end loop;
return ; end;$function$;
But I need to return 2 different tables as optional, that is any one at a execution based on the condition.
For Example: I have 2 table structures.
table(num int, name text)
table(num int, name text, value text)
I need any one of these table structure to return.
How this can be done?