Affect scoping in SQL stored function The condition staff.staffId = staffId in the following stored function apparently always evaluates to true because staffId is scoped to the (inner) column in table staff instead of the (outer) argument of the function endpoint_organizations.

CREATE OR REPLACE FUNCTION endpoint_organizations (staffId INTEGER)
RETURNS TABLE (organizationId INTEGER, name TEXT)
AS $$
  SELECT organizations.organizationId, name 
  FROM organizations
  INNER JOIN staff
  ON staff.organizationId = organizations.organizationId
  WHERE staff.staffId = staffId
$$ LANGUAGE SQL;


Is there are way for affecting the scoping in a concise way that does not require changing the name of the argument e.g. into staffId1. I've tried changing the condition into (staff.staffId AS staffId1) = staffId, but that does not seem to work.
Quote from the manual


  You can also set the behavior on a function-by-function basis, by inserting one of these special commands at the start of the function text:

#variable_conflict error
#variable_conflict use_variable
#variable_conflict use_column



But for readability (and maintainability) I would strongly suggest to rename the variable to something different. 

Many people simply use a prefix for the parameters (e.g. p_staff_id) and also prefixes for local variables (e.g. l_some_var) to make sure they never clash with each other or column names (this is also the de-facto standard in the Oracle world)