Pgsql return table ERROR: column reference is ambiguous

I keep getting this ERROR: the reference to the "person" column is ambiguous.

I need to return a TABLE (integer). It works great when I use the SETOF integer, but in this case it does not work. My other recurse () function perfectly returns a set of integers.

CREATE OR REPLACE FUNCTION try(_group text) RETURNS TABLE (person integer) AS $$ 
DECLARE
     _init_id integer;
     _record integer;
BEGIN
     SELECT id INTO _init_id FROM egroups WHERE name = _group;

    FOR _record in SELECT person FROM egroupdata WHERE egroup IN (SELECT recurse(_init_id))
    LOOP
        RETURN NEXT;
    END LOOP;

END;
$$ language plpgsql stable;
+3
source share
2 answers

Ambiguous column references are associated with more than one column with the same name. In this case, I assume this is a quirk of table return. Try changing the query:

SELECT egroupdata.person FROM egroupdata WHERE egroup IN (SELECT recurse(_init_id))

This will result in a mismatch of the column link.

+17
source

, , . , . :

select a.b, c.b from vsh_a a, vsh_b b where a.id = b.id

tablename . ?

-1

All Articles