title: postgresql iterate n records
body: <p>I have table <strong>student_list</strong> it contains <strong>student_id</strong> only one column and 100 rows.
  i need to fetch 10-10 records concurrently  and then perform some operation.</p>
  
  <pre><code> CREATE OR REPLACE FUNCTION loop_fetch()
    RETURNS void AS
  $BODY$
  DECLARE
  myrow student_list%rowtype;
  cur1 CURSOR FOR SELECT * FROM student_list ;
  BEGIN
   OPEN cur1;
      LOOP
      -- i need to fetch rows based on limit
      FETCH NEXT 10 FROM cur1 INTO myrow;
          exit when myrow  IS NULL;
          INSERT INTO new_tbl SELECT myrow.student_id ;
      END LOOP;
      CLOSE cur1;  
  END;
  $BODY$
    LANGUAGE plpgsql VOLATILE;
  </code></pre>
  
  <p>Any suggestion to achive this method -  FETCH NEXT 5 FROM cur1 INTO myrow </p>