My understanding of ambiguous fields, or where I see the error elsewhere, is when I've defined a JOIN on multiple records and failed to specifically say which table has the field when the field names are identical.
What I have is (generalized):
INSERT INTO schema_a.table_a(f1,f2,f3,f4,f5,f6)
VALUES(v1,v2,v3,v4,v5,v6)
ON CONFLICT(f1,f2)
DO UPDATE SET (f6) = (f6 + 1)
WHERE schema_a.table_a.f1 = v1 and schema_a.table_a.f2 = v2;
During an update there isn't anything that actually needs to be updated, or is new. I'm preventing PK failures during import by doing this, which should be harmless overall. f6 is just an small integer that gets incremented whenever the record is added again.
PostgreSQL complains that the column f6 is ambiguous, yet there is only 1 table, and exactly one field named f6.
column reference "f6" is ambiguous
Modifying the UPDATE portion by adding the schema and/or table (schema_a.table_a.f6 +1) results in:
column reference "f1" is ambiguous
I can't understand how any part of it, is at all is ambiguous. There isn't a 2nd field anywhere that is identical that the SQL is "touching", and there is only ONE table.
Any help is appreciated.
* Update *
There was a claim I wasn't giving all the information. The following SQL runs inside a trigger function. You will notice the comment tag. The SQL is working as long as the comment tags and the ';' after values are gone. This SQL is exactly exactly the same with the exception that schema, table, field, and value names have been changed with regex replace statements.
INSERT INTO schema_a.table_a(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11)
VALUES(wrk_f1,wrk_f2,wrk_f3,wrk_f4,wrk_f5,wrk_f6,wrk_f7,wrk_f8,wrk_f9,wrk_f10,0);
/*ON CONFLICT (f1,f7)
DO UPDATE SET (f11) = (f11 + 1)
WHERE f1 = wrk_f1 AND f7 = NEW.f7 AND f4 = wrk_f4;*/
SET
part you have to qualify the column name - just as I have shown in my answer.