title: Looping in PostgreSQL
body: <p>I am new to PostgreSQL and have a simple task with a looping structure.</p>
  
  <p>Trying to print 0 to 10. Here is my function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION LOOPING()
  RETURNS TABLE(asd text) AS
  $BODY$declare 
  i integer;      
  Begin       
  
  i:=0;
  WHILE i &gt; 10  LOOP
    select  i;
    i:=(i+1);
  END LOOP;
  
  end;$BODY$
  LANGUAGE plpgsql IMMUTABLE
  COST 100
  ROWS 1000;
  ALTER FUNCTION LOOPING()
  OWNER TO postgres;
  </code></pre>
  
  <p>I have tried with while loop. If anybody can do this task with for loop it will be very helpful.</p>