title: How to set a variable inside do block in postgres (sql file)
body: <p>This is the oracle sql code</p>
  
  <pre><code>    variable retval number
      set pagesize 0 feedback off verify off heading off echo off
      DECLARE
      retval numeric;
      p_ret numeric(9) ;
  
      BEGIN
      begin
  
       test();
              p_ret := 0;
  
              EXCEPTION
                      WHEN OTHERS THEN
                              p_ret := sqlcode ;
      end ;
  
      :retval := ( p_ret  ) ;
   END ;
   /
  exit  :retval;
  /
  </code></pre>
  
  <p>Variable retval is being set inside the block.
  What is the equivalent in postgresql?</p>