title: How to declare local variables in postgresql?
body: <p>There is an almost identical, but not really answered question <a href="https://stackoverflow.com/questions/1490942/how-to-declare-a-variable-in-a-postgresql-query">here</a>.</p>
  
  <p>I am migrating an application from MS SQL Server to PostgreSQL. In many places in code I use local variables so I would like to go for the change that requires less work, so could you please tell me which is the best way to translate the following code?</p>
  
  <pre><code>-- MS SQL Syntax: declare 2 variables, assign value and return the sum of the two 
  declare @One integer = 1
  declare @Two integer = 2
  select @One + @Two as SUM
  </code></pre>
  
  <p>this returns:</p>
  
  <pre><code>SUM
  -----------
  3
  
  (1 row(s) affected)
  </code></pre>
  
  <p>I will use Postgresql 8.4 or even 9.0 if it contains significant fetaures that will simplify the translation.</p>