title: while function in postgresql
body: <p>I want to insert records to a table by function. </p>
  
  <pre><code>CREATE OR REPLACE FUNCTION insert_wilda()
      RETURNS integer AS
  $BODY$
  DECLARE
      countKab integer;
      i integer;
  BEGIN
      i := 1;
      SELECT count(*)+34 into countKab from m_kab
      WHILE (i &lt;= countKab)
      loop
  
          INSERT INTO "t_historyWilda"("kdHistory","kdProp","kdKab","kdKec","nmWilda","noUrut",bulan,tahun,"isActive")
          SELECT 'i',"kdProp","kdKab",'000',"namaKab",'1', EXTRACT(MONTH FROM TIMESTAMP 'now()'), EXTRACT(YEAR FROM TIMESTAMP 'now()'),'1' FROM m_kab
      end loop;
      RETURN i;
  END;
  $BODY$
      LANGUAGE plpgsql VOLATILE
      COST 100;
  </code></pre>
  
  <p>But I got error like this: </p>
  
  <pre><code>ERROR:  syntax error at or near "&lt;="
  LINE 10:  WHILE (i &lt;= countKab)
                     ^
  
  ********** Error **********
  
  ERROR: syntax error at or near "&lt;="
  </code></pre>