title: How do I reference named parameters in Postgres sql functions?
body: <p>Postgres noobie here.</p>
  
  <p>I'm trying to convert a SQL Server stored proc into a Postgres function.  Currently cannot figure out how to turn this SQL line into Postgres.</p>
  
  <p>SQL Server:</p>
  
  <pre><code>input: @name = null
  
  SELECT *
  FROM table
  WHERE name = ISNULL(@name, name)
  </code></pre>
  
  <p>Postgres:</p>
  
  <pre><code>input: n = null
  
  SELECT *
  FROM table
  WHERE name = COALESCE(n, name)
  </code></pre>
  
  <p>I'm getting the error "column n does not exist."  How do I reference parameters in select statements in Postgres functions?</p>
  
  <p>UPDATE:</p>
  
  <p>Definition of Postgres function</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION fn_name (n VARCHAR(32) = NULL, name OUT varchar(32), description OUT varchar(64))
  RETURNS setof record
  AS 
  $$
      SELECT u.name
          , u.description
      FROM table_a u
      WHERE u.name = COALESCE(n, u.name);
  
  $$
  LANGUAGE sql;
  </code></pre>