title: It could refer to either a PL/pgSQL variable or a table column
body: <p>I have a function in pgsql</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION core.date_bs_from_ad(date_in_ad date)
    RETURNS character varying AS
  $$
  BEGIN
      RETURN(
          SELECT date_in_bs FROM core.date_conversion
          WHERE date_in_ad = $1
      );
  END
  $$
  
    LANGUAGE plpgsql;
  </code></pre>
  
  <p>It is created with no errors, but when i use this function it through following error:</p>
  
  <pre><code>ERROR:  column reference "date_in_ad" is ambiguous
  LINE 3:   WHERE date_in_ad = $1
                  ^
  DETAIL:  It could refer to either a PL/pgSQL variable or a table column.
  QUERY:  SELECT (
          SELECT MAX(date_in_bs) FROM core.date_conversion
          WHERE date_in_ad = $1
      )
  CONTEXT:  PL/pgSQL function core.date_bs_from_ad(date) line 3 at RETURN
  ********** Error **********
  
  ERROR: column reference "date_in_ad" is ambiguous
  SQL state: 42702
  Detail: It could refer to either a PL/pgSQL variable or a table column.
  Context: PL/pgSQL function core.date_bs_from_ad(date) line 3 at RETURN
  </code></pre>