create function test(a integer, b integer)
returns table (a integer, b integer) as $$
begin
return query select 1, 2;
end;
$$ language plpgsql;
throws exception:
ERROR: parameter name "a" used more than once
CONTEXT: compilation of PL/pgSQL function "test" near line 1
Why this is happening? I thought that function argument name has nothing to do with returned table column name. Is there a workaround to have function argument named "a" and also have column named "a" in a table returned from function?
I know that I can return setof record
but then I have to explicitly "define" columns returned from function in select query:
create function test(a integer, b integer)
returns setof record as $$
begin
return query select 1, 2;
end;
$$ language plpgsql;
select * from test(1, 2) as (a integer, b integer)