title: PostgreSql - Declare integer variable
body: <p>I'm trying to declare integer variable with default value 0 in postgresql sql script:</p>
  
  <pre><code>DECLARE user_id integer;
  </code></pre>
  
  <p>but it returns exception:</p>
  
  <blockquote>
    <p>ERROR: syntax error at or near "integer"</p>
  </blockquote>
  
  <p>I'm not sure how can I declare a variable and then use this variable inside while loop.</p>