title: Postgresql function with if statement
body: <p>How can I make this pseudo code to work in Postgresql:</p>
  
  <pre><code>create or replace function getf(arg character varying(255)) returns int
  as $$
  if arg = 'a' then return 1;
  else return 2;
  $$ language sql;
  </code></pre>
  
  <p>Based on argument I need to return some values and there is no other table I need to query. Just need to build a logic inside function.
  Tried to replace if with when clause, but could not figure out how to do it.</p>
  
  <p>Thanks!</p>