Sample Header Ad - 728x90

(postgre)SQL how to disambiguate a name that could be a column name or a table alias

2 votes
1 answer
295 views
In PostgreSQL anyway you can pass a table (row) alias into a function and it will pass the entire record in. But when you have a table alias x and also a column name x, when you specify f(x) it will not know which one, throw error "ambiguous name x" or pass the wrong one. Obviously it is easy to disambiguate for the column name: just precede with it's table alias: t.x. But what if I want to disambiguate for the table alias? Simple example: select f(x) from (select 1 x) x Obviously I can avoid having those clashes by renaming either the table alias or the column, but there should be a way to say "!x" or "table x" or whatever to force a reference to the table alias (or row variable).
Asked by Gunther Schadow (523 rep)
Jan 1, 2023, 10:53 AM
Last activity: Jan 1, 2023, 07:19 PM